Skip to content

Default dev certificate not working with Http3 #41762

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

Open
1 task done
Daniel-Genkin-MS-2 opened this issue May 19, 2022 · 13 comments
Open
1 task done

Default dev certificate not working with Http3 #41762

Daniel-Genkin-MS-2 opened this issue May 19, 2022 · 13 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-kestrel HTTP3

Comments

@Daniel-Genkin-MS-2
Copy link
Contributor

Daniel-Genkin-MS-2 commented May 19, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I tried to run the Http3Sample but found that the server rejects all the Http3 requests made to it from the browser (Edge Version 101.0.1210.47). However, a simple C# script that I wrote can reach the server over Http/3:

using System.Net;

var handler = new SocketsHttpHandler();
handler.SslOptions = new System.Net.Security.SslClientAuthenticationOptions
{
    RemoteCertificateValidationCallback = (_, __, ___, ____) => true
};

HttpClient client = new HttpClient(handler);
var result = await client.SendAsync(new HttpRequestMessage(HttpMethod.Get, "https://127.0.0.1:5001")
{
    Version = HttpVersion.Version30,
    VersionPolicy = HttpVersionPolicy.RequestVersionExact
}, CancellationToken.None);

Console.WriteLine(await result.Content.ReadAsStringAsync());

I also noticed that if I replace the existing certificate

var cert = CertificateLoader.LoadFromStoreCert("localhost", StoreName.My.ToString(), StoreLocation.CurrentUser, false);

with a newly generated one (see script below), then I can connect to the server via WebTransport APIs in DevTools. The main browser still is refused though.

var now = DateTimeOffset.UtcNow;
SubjectAlternativeNameBuilder sanBuilder = new();
sanBuilder.AddDnsName("localhost");
using var ec = ECDsa.Create(ECCurve.NamedCurves.nistP256);
CertificateRequest req = new("CN=localhost", ec, HashAlgorithmName.SHA256);
req.CertificateExtensions.Add(new X509EnhancedKeyUsageExtension(new OidCollection
{
    new("1.3.6.1.5.5.7.3.1") // serverAuth
}, false));
req.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.DigitalSignature, false));
req.CertificateExtensions.Add(sanBuilder.Build());
using var crt = req.CreateSelfSigned(now, now.AddDays(14));
cert = new(crt.Export(X509ContentType.Pfx));

The above code snippet was taken from https://github.com/wegylexy/webtransport, which seems to have a WebTransport and http/3 server working in C#.

Expected Behavior

I should be able to fetch the Hello, World! Http/3 via the browser. However, I always either get Hello, World! Http/2 or the browser connection refused message.

Steps To Reproduce

  1. Modify the line 43:
options.ListenAnyIP(5001, listenOptions =>

To become

options.Listen(IPAddress.Any, 5001, listenOptions =>

(This avoids the known bug that prevents the connection)

  1. Open a browser and go to https://localhost:5001.

You can also modify the listenOptions.Protocols to only include Http/3. In those cases, it always times out instead of just always defaulting to Http/2.

Exceptions (if any)

No response

.NET Version

No response

Anything else?

Microsoft Visual Studio Enterprise 2022 (64-bit) - Preview
Version 17.3.0 Preview 1.0

(aspnetcore) PS C:\aspnetcore> dotnet --info
.NET SDK:
Version: 7.0.100-preview.5.22228.6
Commit: f59d2cfdfe

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22000
OS Platform: Windows
RID: win10-x64
Base Path: C:\aspnetcore.dotnet\sdk\7.0.100-preview.5.22228.6\

global.json file:
C:\aspnetcore\global.json

Host:
Version: 7.0.0-preview.5.22254.12
Architecture: x64
Commit: 874c6a9375

.NET SDKs installed:
7.0.100-preview.5.22228.6 [C:\aspnetcore.dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.0-preview.5.22228.1 [C:\aspnetcore.dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.0-preview.5.22226.6 [C:\aspnetcore.dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0-preview.5.22254.12 [C:\aspnetcore.dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 7.0.0-preview.5.22226.7 [C:\aspnetcore.dotnet\shared\Microsoft.WindowsDesktop.App]

@adityamandaleeka
Copy link
Member

Triage: let's see what we can do to make the dev experience better.

@adityamandaleeka adityamandaleeka added this to the .NET 7 Planning milestone May 20, 2022
@ghost
Copy link

ghost commented May 20, 2022

Thanks for contacting us.

We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@ghost
Copy link

ghost commented Sep 9, 2022

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@MychellSantos
Copy link

I was in doubt if http3 needs a certificate inside the application in the container, because my certificates are in the proxy/nginx.
my application doesn't even know if it has a certificate or not.

@Tratcher
Copy link
Member

Tratcher commented Nov 16, 2022

HTTP/3 always requires a certificate, there's no un-encrypted format for it. In this case it would be encrypted between the proxy and your app.

However, does your proxy even support HTTP/3 proxying? Even if it supports HTTP/3 on the front end, it's likely downgrading on the back end. Last I heard it barely supported HTTP/2 proxying.

@MychellSantos
Copy link

MychellSantos commented Nov 16, 2022

from what I understand, within my kestrel I have to inform a certificate, BUT
for http3 it needs https, for https it needs a certificate for kestrel, and my certificate is on the proxy.
and we're not even talking dev experience better.

@Tratcher
Copy link
Member

Is there a specific reason you want HTTP/3 behind the proxy? HTTP/3's benefits are mainly on public networks, using HTTP/1.x or HTTP/2 between the proxy and your app is normally fine. The proxy should be able to handle HTTP/3 for you and downgrade for the backend.

@MychellSantos
Copy link

@Tratcher I'm looking for network requirements, with performance latency and etc...
however, if the "proxy, nginx service mesh" delivers http3 to me, and my kestrel uses http, I believe that the kestrel using http3 could also be more harmonic

@Tratcher
Copy link
Member

Not necessarily. A) you'll have to find out if your proxy even supports proxying it. B) HTTP/3 was designed for unstable external networks, it's not especially helpful on stable internal networks. And since it requires encryption, that adds overhead that HTTP/1.x wouldn't have for the backend.

@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 2, 2023
@vsg24
Copy link

vsg24 commented Jan 4, 2024

any updates on this? it's been such a long time

@amcasey
Copy link
Member

amcasey commented Feb 14, 2024

@vsg24 What action are you looking for here? Based on the back and forth, it seems like there was some question as to whether the scenario was even worthwhile. Is the issue that the sample doesn't work as written? If so, have you confirmed in a more recent build of aspnetcore?

@amcasey
Copy link
Member

amcasey commented Feb 14, 2024

We might fix a bug in a sample app, but HTTP/3 isn't a focus in 9.0.

@vsg24
Copy link

vsg24 commented Feb 19, 2024

@amcasey I expect the default implementation to just work so we don't have to resort to writing all that extra code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-kestrel HTTP3
Projects
None yet
Development

No branches or pull requests

6 participants