Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HTTP/3] Certificate name validation different than HTTP/1.1? #55193

Closed
JamesNK opened this issue Jul 6, 2021 · 8 comments · Fixed by #56175
Closed

[HTTP/3] Certificate name validation different than HTTP/1.1? #55193

JamesNK opened this issue Jul 6, 2021 · 8 comments · Fixed by #56175
Assignees
Milestone

Comments

@JamesNK
Copy link
Member

JamesNK commented Jul 6, 2021

I have a Kestrel server configured to serve HTTP/1.1 and HTTP/3 on the same port with the same certificate. The certificate is the ASP.NET Core development certificate.

HttpClient throws this error when calling with HTTP/1.1:

    System.Net.Http.HttpRequestException : The SSL connection could not be established, see inner exception.
    ---- System.Security.Authentication.AuthenticationException : The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

I need to setup a handler with ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator to successfully call it.

Meanwhile, HttpClient calling HTTP/3 doesn't need the validation callback. It happily accepts the dev certificate as trusted.

Should HTTP/1.1 and HTTP/2 have different certificate validation behavior than HTTP/3?

@ghost
Copy link

ghost commented Jul 6, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

I have a Kestrel server configured to serve HTTP/1.1 and HTTP/3 on the same port with the same certificate. The certificate is the ASP.NET Core development certificate.

HttpClient throws this error when calling with HTTP/1.1:

    System.Net.Http.HttpRequestException : The SSL connection could not be established, see inner exception.
    ---- System.Security.Authentication.AuthenticationException : The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

I need to setup a handler with ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator to successfully call it.

Meanwhile, HttpClient calling HTTP/3 doesn't need the validation callback. It happily accepts the dev certificate as trusted.

Author: JamesNK
Assignees: -
Labels:

area-System.Net.Http

Milestone: -

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Jul 6, 2021
@wfurt
Copy link
Member

wfurt commented Jul 6, 2021

I assume this is on Windows? Can you please post your dev certificate? I would not expect differences but this would help with investigation.

@JamesNK
Copy link
Member Author

JamesNK commented Jul 6, 2021

Yes, this is Windows.

Password is "quic"
devcert.zip

btw my test has the client calling 127.0.0.1. Dev cert is for localhost.

@ManickaP ManickaP removed the untriaged New issue has not been triaged by the area owner label Jul 6, 2021
@ManickaP ManickaP added this to the 6.0.0 milestone Jul 6, 2021
@wfurt
Copy link
Member

wfurt commented Jul 7, 2021

Is the certificate trusted @JamesNK ? I used code from #55192 without the validation callback and it works fine for me:

C:\Users\test\source\repos\h3> C:\Users\test\source\repos\h3\bin\Debug\net6.0\win-x64\publish\h3
Hello World! HTTP/3

Now the mapping 127.0.0.1 <-> localhost should not work IMHO unless the address is in AlternativeSubjectName.

@JamesNK
Copy link
Member Author

JamesNK commented Jul 7, 2021

I think the cert is trusted.

The issue isn't that HttpClient failed to make an HTTP/3 call. It succeeds on my computer. The issue is that HttpClient gets a validation error for HTTP/1.1 and HTTP/2.

Why are they different? Why doesn't HTTP/3 complain that the host name and certificate name are different?

@wfurt
Copy link
Member

wfurt commented Jul 7, 2021

I understand but I was not able to reproduce it. I assume it works if you use the localhost? Perhaps you can create simple repro with both client & server and cert from file?

@JamesNK
Copy link
Member Author

JamesNK commented Jul 7, 2021

Repo is in dotnet/aspnetcore#34104

Test: Listen_Http3AndSocketsCoexistOnSameEndpoint_ClientSuccess. The CallHttp3AndHttp1EndpointsAsync method specifically. HTTP/3 call works without a callback, while HTTP/1.1 call requires it.

@wfurt
Copy link
Member

wfurt commented Jul 7, 2021

I get it now. The complain is that QICK/H3 work but it should not. I know what the problem is.

@wfurt wfurt self-assigned this Jul 7, 2021
@karelz karelz changed the title HTTP/3: Certificate name validation different than HTTP/1.1? [HTTP/3] Certificate name validation different than HTTP/1.1? Jul 12, 2021
@ManickaP ManickaP added the bug label Jul 15, 2021
@ManickaP ManickaP assigned ManickaP and unassigned wfurt and ManickaP Jul 15, 2021
@ManickaP ManickaP self-assigned this Jul 22, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 22, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 23, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants