HTTPS requests fail on .NET Core 2.1 under a proxy, the response is a 407 proxy required error.
I've made a repo demonstrating it working under netcore20 and not under netcore21: https://github.com/talanc/dotnetcore-proxytest
You need to be in a proxy environment for netcore21 to fail.
Background: I was in the process of converting an ASP.NET Core 2.0 application to 2.1 and I saw 1 of my tests fail when moving the target framework from netcore20 to netcore21 (no code changes). I thought it was a bit odd because I have two very similar tests with the only difference being 1 does a HTTP GET and the other does HTTPS GET.
Environment: I'm running Windows 7 (x64) under a corporate network proxy.
I'm willing to help with testing potential fixes and workarounds.
This is probably a dupe of dotnet/runtime#26462
Will this get a fix in a 2.1.X update?
Will this get a fix in a 2.1.X update?
Yes, we plan to put this into a servicing release of 2.1 in the next few months.
Closing as dupe of dotnet/runtime#26462
@talanc if you can verify on our daily builds (see how) that it is addressed, it would help us a lot!
It's not fixed, but it does return a different exception:
System.Net.Http.HttpRequestException: Authentication failed because the connection could not be reused.
Stack Trace:
at System.Net.Http.HttpConnection.DrainResponseAsync(HttpResponseMessage response)
at System.Net.Http.AuthenticationHelper.SendWithNtAuthAsync(HttpRequestMessage request, Uri authUri, ICredentials credentials, Boolean isProxyAuth, HttpConnection connection, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.AuthenticationHelper.SendWithAuthAsync(HttpRequestMessage request, Uri authUri, ICredentials credentials, Boolean preAuthenticate, Boolean isProxyAuth, Boolean doRequestAuth, HttpConnectionPool pool, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.EstablishProxyTunnel(CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at ProxyTest.Class1.Api(String url) in C:\src\dotnetcore-proxytest\ProxyLib\Class1.cs:line 17
at ProxyTest.Class1.Https() in C:\src\dotnetcore-proxytest\ProxyLib\Class1.cs:line 28
at ProxyTest22_Preview1_26620_03.NetCore22_Preview1_26620_03_Tests.NetCore22_Https() in C:\src\dotnetcore-proxytest\ProxyTest-2.2-preview1-26620-03\NetCore22_Preview1_26620_03_Tests.cs:line 19
repo: https://github.com/talanc/dotnetcore-proxytest
dotnet info: https://github.com/talanc/dotnetcore-proxytest/blob/master/dotnet-info.txt
project file: https://github.com/talanc/dotnetcore-proxytest/blob/master/ProxyTest-2.2-preview1-26620-03/ProxyTest-2.2-Preview1-26620-03.csproj
That exception is bug dotnet/runtime#26461. Now that you have a fix for dotnet/runtime#26462, you are getting an exception due to your proxy server closing the first connection after the 407 response. That is issue dotnet/runtime#26461 which has not yet been fixed.