You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using WebClient and HttpWebRequest to call external Http APIs and is dependent on a proxy to make external calls. After upgrading to .Net Core Preview 7 I get Proxy authentication error (407). The code runs ok in .Net Core 2.1, and .Net Core 3 preview 3.
This is a snippet that
succeeds on .Net Core 2.1 & 3.0 preview 3
but fails on preview 7,
running in Visual Studio 2019 16.2.0:
stringproxy=<_name of Proxy_>;string url ="https://www.kemi.se/global/faktablad/faktablad-om-sakerhetsdatablad.pdf";varclient=newWebClient(){Proxy=newWebProxy(proxy,8080){UseDefaultCredentials=true}};vardata=client.DownloadData(url);
I tried to reproduce this with .NET Core 3.0 Preview 7 but I wasn't able to. I used a proxy (running on "localhost") and it was able to respond to the 407 and send back the appropriate 'Proxy-Authorization: Negotiate base64blob' headers to the proxy.
Have you tried running your program outside of Visual Studio?
I am running Windows 10. As a workaround I reverted to .Net Core Preview 6, no problem in that version it seems. Since WebClient/HttpWebRequest fits my code pattern I have not tried HttpClient.
Summary:
OS: Windows 10
Visual studio: Visual Studio 2019 16.2.0
.Net Core 2.1: OK
.Net Core 3.0 Preview 3 OK
.Net Core 3.0 Preview 6 OK
.Net Core 3.0 Preview 7 Failure ( Proxy authentication error)
I reverted to Preview 6 before I saw your question about running outside Visual Studio. I have only tried running from Visual Studio since I'm in development right now.. Our proxy is on a central server.
I have only tried running from Visual Studio since I'm in development right now..
I just tried the repro using Visual Studio 2019 16.2.0. I'm still not getting a 407 error. It is able to send credentials to the proxy and do the request to the server.
Can you collect a Wireshark trace of this scenario? It will show what is going on and we can diagnose it further.
Now I switched back to .Net Core Preview 7 and the problem reappear. Success in preview 6 and failure in preview 7. The failure occurs when running outside Visual Studio as well. I am using x64:
Summary:
OS: Windows 10
Visual studio: Visual Studio 2019 16.2.0
Platform: .Net Core x64
Occurs outside Visual Studio as well.
.Net Core 2.1: OK
.Net Core 3.0 Preview 3 OK
.Net Core 3.0 Preview 6 OK
.Net Core 3.0 Preview 7 Failure ( Proxy authentication error)
I need permission to use Wireshark in my organisation. We are in timezone UTC+2 so I have to wait until tomorrow before I can have traces.
Ok. Please do not post any traces that contain confidential or proprietary information. You can remove any of that info prior to posting. Or perhaps post screenshots of traces masking out confidential information.
It does sound like something is going on since your proxy scenario is working in Preview 6 but not Preview 7. But I'm not able to reproduce the problem. It could be related to something more specific in your corporate environment. The traces will help.
The Proxy authentication token seems to differ between preview 6 and 7:
Preview 7:
Proxy-Authorization: Negotiate .... (56 bytes, padded with == a end and followed by CR/LF) [Failure]
Preview 6:
Proxy-Authorization: Negotiate ... (does not see padding or any CR/LF) [OK]
I did a quick hack to create a middle man process and injected it between the application and the proxy server to log the dialogue. The call did not get through, might due to my error or some protection in the protocol to prevent middle mans, but the result was:
Preview 7:
Proxy-Authorization: Negotiate .... (56 bytes, padded with == a end and followed by CR/LF) [Failure]
Preview 6:
Proxy-Authorization: Negotiate ... (176 bytes, no padding and followed by CR/LF) [Failure]
Preview 6:
Proxy-Authorization: Negotiate ... (does not see padding or any CR/LF) [OK]
I don't quite understand this. The 'Proxy-Authorization' header should always have CR/LF after it. Just like any other header in the request. Are you saying that it's missing entirely?
I did a quick test between .NET Core 2.1 and .NET Core 3.0 Preview 7. I wrote a small test app that connects to an HTTPS server thru an authenticating proxy server that uses Negotiate scheme.
I see a difference in the base64 blob that is sent. For example:
You'll notice in the .NET Core 2.1 case, the base64 token begins with "Y". That means that SPNEGO (Kerberos) protocol is being used against the 'Negotiate' scheme offered by the proxy.
But in the .NET Core 3.0 Preview 7 case, the base64 token begins with "T". That means that NTLM is being used against the 'Negotiate' scheme offered by the proxy.
My guess is that your corporate proxy is very strict and requires SPNEGO protocol only when 'Negotiate' is challenged.
Can you confirm that you see a similar difference in the base64 tokens for the 'Proxy-Authorization' request headers that are being sent? Thanks.
By the way, I didn't see any problem when connecting to a non-HTTPS server thru an authenticating proxy. It always seemed to use SPNEGO protocol for both .NET Core 2.1 and .NET Core 3.0 Preview 7.
I can see that this is closed, but I can still see this issue using latest release of net core 3.0 on Windows. All http requests withing domain via authenticated proxy are blocked. Reverting to net core 2.2 works fine
@marekpetak This issue is closed. Please open a new issue. Also, please include the output of "dotnet --info" so that we know the exact versions of the runtime you are using.
Please include a repro that we can run. At least include the client code you are using, i.e. HttpClient? HttpWebRequest? WebClient? What sort of credentials are you setting? "DefaultCredentials" or explicit credentials? What are the authentication schemes asked by your proxy? Negotiate? NTLM?
I can see that this is closed, but I can still see this issue using latest release of net core 3.0 on Windows. All http requests withing domain via authenticated proxy are blocked. Reverting to net core 2.2 works fine
I also the same issue when trying a call to another web API.
The Log message is "HttpResponseMessage: Proxy Authentication Required".
@khiemnvd it is likely your issue is actually a different problem than @marekpetak.
@khiemnvd was your solution working before and now only recently broke?
Please open a new issue. These problems can not be investigated since this issue is closed.
And looking at the code you provided, it doesn't give us enough information diagnose. It you are getting a 407 Proxy Authentication Required than you need to be passing in credentials to your proxy? But I don't see any code for that in the sample you provided.
Activity
stephentoub commentedon Jul 30, 2019
cc: @davidsh
davidsh commentedon Jul 30, 2019
@roglainc Can you give a few more details? Is this on Windows or Linux? I'm thinking Windows because you mention Visual Studio 2019.
Have you also tried HttpClient as well?
davidsh commentedon Jul 30, 2019
I tried to reproduce this with .NET Core 3.0 Preview 7 but I wasn't able to. I used a proxy (running on "localhost") and it was able to respond to the 407 and send back the appropriate 'Proxy-Authorization: Negotiate base64blob' headers to the proxy.
Have you tried running your program outside of Visual Studio?
roglainc commentedon Jul 30, 2019
I am running Windows 10. As a workaround I reverted to .Net Core Preview 6, no problem in that version it seems. Since WebClient/HttpWebRequest fits my code pattern I have not tried HttpClient.
Summary:
OS: Windows 10
Visual studio: Visual Studio 2019 16.2.0
.Net Core 2.1: OK
.Net Core 3.0 Preview 3 OK
.Net Core 3.0 Preview 6 OK
.Net Core 3.0 Preview 7 Failure ( Proxy authentication error)
roglainc commentedon Jul 30, 2019
I reverted to Preview 6 before I saw your question about running outside Visual Studio. I have only tried running from Visual Studio since I'm in development right now.. Our proxy is on a central server.
davidsh commentedon Jul 30, 2019
I just tried the repro using Visual Studio 2019 16.2.0. I'm still not getting a 407 error. It is able to send credentials to the proxy and do the request to the server.
Can you collect a Wireshark trace of this scenario? It will show what is going on and we can diagnose it further.
roglainc commentedon Jul 30, 2019
Now I switched back to .Net Core Preview 7 and the problem reappear. Success in preview 6 and failure in preview 7. The failure occurs when running outside Visual Studio as well. I am using x64:
Summary:
OS: Windows 10
Visual studio: Visual Studio 2019 16.2.0
Platform: .Net Core x64
Occurs outside Visual Studio as well.
.Net Core 2.1: OK
.Net Core 3.0 Preview 3 OK
.Net Core 3.0 Preview 6 OK
.Net Core 3.0 Preview 7 Failure ( Proxy authentication error)
davidsh commentedon Jul 30, 2019
If you could collect Wireshark traces for both the preview 6 and preview 7 cases that would be useful. We can then compare them.
roglainc commentedon Jul 30, 2019
I need permission to use Wireshark in my organisation. We are in timezone UTC+2 so I have to wait until tomorrow before I can have traces.
davidsh commentedon Jul 30, 2019
Ok. Please do not post any traces that contain confidential or proprietary information. You can remove any of that info prior to posting. Or perhaps post screenshots of traces masking out confidential information.
It does sound like something is going on since your proxy scenario is working in Preview 6 but not Preview 7. But I'm not able to reproduce the problem. It could be related to something more specific in your corporate environment. The traces will help.
roglainc commentedon Jul 31, 2019
Now I have traces from preview 6 (ok)


and preview7 (failure)
roglainc commentedon Jul 31, 2019
The Proxy authentication token seems to differ between preview 6 and 7:
Preview 7:
Proxy-Authorization: Negotiate .... (56 bytes, padded with == a end and followed by CR/LF) [Failure]
Preview 6:
Proxy-Authorization: Negotiate ... (does not see padding or any CR/LF) [OK]
I did a quick hack to create a middle man process and injected it between the application and the proxy server to log the dialogue. The call did not get through, might due to my error or some protection in the protocol to prevent middle mans, but the result was:
Preview 7:
Proxy-Authorization: Negotiate .... (56 bytes, padded with == a end and followed by CR/LF) [Failure]
Preview 6:
Proxy-Authorization: Negotiate ... (176 bytes, no padding and followed by CR/LF) [Failure]
davidsh commentedon Jul 31, 2019
I don't quite understand this. The 'Proxy-Authorization' header should always have CR/LF after it. Just like any other header in the request. Are you saying that it's missing entirely?
davidsh commentedon Jul 31, 2019
I think I am beginning to see a problem now.
I did a quick test between .NET Core 2.1 and .NET Core 3.0 Preview 7. I wrote a small test app that connects to an HTTPS server thru an authenticating proxy server that uses Negotiate scheme.
I see a difference in the base64 blob that is sent. For example:
You'll notice in the .NET Core 2.1 case, the base64 token begins with "Y". That means that SPNEGO (Kerberos) protocol is being used against the 'Negotiate' scheme offered by the proxy.
But in the .NET Core 3.0 Preview 7 case, the base64 token begins with "T". That means that NTLM is being used against the 'Negotiate' scheme offered by the proxy.
My guess is that your corporate proxy is very strict and requires SPNEGO protocol only when 'Negotiate' is challenged.
Can you confirm that you see a similar difference in the base64 tokens for the 'Proxy-Authorization' request headers that are being sent? Thanks.
By the way, I didn't see any problem when connecting to a non-HTTPS server thru an authenticating proxy. It always seemed to use SPNEGO protocol for both .NET Core 2.1 and .NET Core 3.0 Preview 7.
4 remaining items
Fix SocketsHttpHandler proxy auth for 'Negotiate' scheme (#39933)
davidsh commentedon Aug 1, 2019
Fixed in master branch for .NET Core 5.0 with PR dotnet/corefx#39933
davidsh commentedon Aug 1, 2019
Re-opening for release/3.0 fix.
Fix SocketsHttpHandler proxy auth for 'Negotiate' scheme (#39933) (#3…
davidsh commentedon Aug 5, 2019
Fixed in release/3.0 with PR dotnet/corefx#39981. Fix will be available in .NET Core 3.0 Preview 8.
marekpetak commentedon Nov 11, 2019
I can see that this is closed, but I can still see this issue using latest release of net core 3.0 on Windows. All http requests withing domain via authenticated proxy are blocked. Reverting to net core 2.2 works fine
davidsh commentedon Nov 11, 2019
@marekpetak This issue is closed. Please open a new issue. Also, please include the output of "dotnet --info" so that we know the exact versions of the runtime you are using.
Please include a repro that we can run. At least include the client code you are using, i.e. HttpClient? HttpWebRequest? WebClient? What sort of credentials are you setting? "DefaultCredentials" or explicit credentials? What are the authentication schemes asked by your proxy? Negotiate? NTLM?
Thanks.
khiemng commentedon Nov 12, 2019
I also the same issue when trying a call to another web API.
The Log message is "HttpResponseMessage: Proxy Authentication Required".
API Startup.cs:
Client Code:
davidsh commentedon Nov 12, 2019
@khiemnvd it is likely your issue is actually a different problem than @marekpetak.
@khiemnvd was your solution working before and now only recently broke?
Please open a new issue. These problems can not be investigated since this issue is closed.
And looking at the code you provided, it doesn't give us enough information diagnose. It you are getting a 407 Proxy Authentication Required than you need to be passing in credentials to your proxy? But I don't see any code for that in the sample you provided.