-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Http/3 client certificates #35308
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 client certificates #35308
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,17 +3,27 @@ | |
|
||
using System.Net; | ||
using System.Net.Http; | ||
using System.Security.Cryptography.X509Certificates; | ||
using Microsoft.AspNetCore.Testing; | ||
|
||
// Console.WriteLine("Ready"); | ||
// Console.ReadKey(); | ||
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meant to still be here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, these are useful if you try to debug the Http3SampleApp. You either have to start the client first and then debug the server, or start both with debugging enabled on the server, and this pause lets you wait until the server is ready. |
||
|
||
var handler = new SocketsHttpHandler(); | ||
handler.SslOptions.RemoteCertificateValidationCallback = (_, _, _, _) => true; | ||
handler.SslOptions.ClientCertificates = new X509CertificateCollection(new[] { TestResources.GetTestCertificate("eku.client.pfx") }); | ||
|
||
using var client = new HttpClient(handler); | ||
client.DefaultRequestVersion = HttpVersion.Version20; | ||
client.DefaultRequestVersion = | ||
HttpVersion.Version20; | ||
// HttpVersion.Version30; | ||
client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher; | ||
|
||
var response = await client.GetAsync("https://localhost:5001"); | ||
var response = await client.GetAsync("https://localhost:5003"); | ||
Console.WriteLine(response); | ||
Console.WriteLine(await response.Content.ReadAsStringAsync()); | ||
|
||
// Alt-svc enables an upgrade after the first request. | ||
response = await client.GetAsync("https://localhost:5001"); | ||
response = await client.GetAsync("https://localhost:5003"); | ||
Console.WriteLine(response); | ||
Console.WriteLine(await response.Content.ReadAsStringAsync()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left them intentionally for anyone working with client certs.