Repository navigation
Conversation
| var client = new HttpClient (handler); | ||
| var result = await client.GetAsync ("https://httpbin.org/redirect-to?url=https://www.microsoft.com/"); | ||
|
|
||
| Assert.AreEqual (2, callbackCounter); |
There was a problem hiding this comment.
@simonrozsival: why is this 2? Are there any docs around how many times ServerCertificateCustomValidationCallback will be invoked, other than "at least once"? Why is the callback being called twice? Is that a bug? Is that likely to change at any point in the future?
Or should it be 2: once for httpbin.org/redirect-to, and once again for www.microsoft.com, and it's called "once per redirect", i.e. if you "nested" redirects with https://httpbin.org/redirect-to?url=https://httpbin.org/redirect-to?url=…, callbackCounter should be the number of times we hit httpbin.org/redirect-to + 1?
There was a problem hiding this comment.
The callback is called once for every sub-request that's made (the first request + all redirects). In this case, it's called once for httpbin.org/... and once for www.microsoft.com. So callbackCounter should equal to 1 + number of redirects. The SocketsHttpHandler behaves the same way.
|
Draft commit message: |
* main: [Xamarin.Android.Build.Tasks] skip XA1034 logic in some cases (dotnet#7680) [ci] Move OneLocBuild task to scheduled pipeline (dotnet#7679) [Mono.Android] ServerCertificateValidationCallback() and redirects (dotnet#7662) Bump to xamarin/Java.Interop/main@cf80deb7 (dotnet#7664) Localized file check-in by OneLocBuild (dotnet#7668) [api-merge] Correctly compute //method/@deprecated-since (dotnet#7645) [Xamarin.Android.Build.Tasks] _Microsoft.Android.Resource.Designer (dotnet#6427) [Xamarin.Android.Build.Tasks] downgrade d8/r8 `warning` messages to `info` (dotnet#7643) [Xamarin.Android.Build.Tasks] fix cases of missing `@(Reference)` (dotnet#7642) [Xamarin.Android.Build.Tasks] delay ToJniName calls in ManifestDocument (dotnet#7653) [Xamarin.Android.Build.Tasks] fast path for `<CheckClientHandlerType/>` (dotnet#7652)
Fixes #7650
We check if the server certificate hostname matches the request's RequestUri. When the request is redirected to a different host, the verification failed because we tested the next server's hostname against the original request URI. This PR keeps the RequestUri in sync with the redirect status to avoid this problem.