WinHttpRequestCallback.OnRequestSendingRequest was throwing ERROR_WINHTTP_INCORRECT_HANDLE_STATE when trying
to retrieve the WINHTTP_OPTION_SERVER_CERT_CONTEXT during custom server certificate validation. This problem
would repro when POST'ing a request body to a secure (TLS/SSL) server thru an authenticating proxy.
The error was being returned because the request handle was not yet bound to a secure connection. This occurs
while connecting thru a proxy where the CONNECT verb hasn't yet been processed due to the proxy requiring
authentication. Discussions with the WinHTTP team confirmed this analysis and fix.
The fix is to ignore this notification when getting this error. Another notification will be sent once the final
secure connection thru the proxy is completed.
Fixesdotnet/corefx#11973
Commit migrated from https://github.com/dotnet/corefx/commit/9cfe9e3d8fe760fe4970ffd0aab21879c92902c8
Ports the .NET Framework implementation to corefx and adds some tests. There is a large portion of the implementation that's internal and not actually reachable from the exposed surface area, but exists to support SmtpClient. I've left that code in so as to enable subsequent porting of System.Net.Mail; at that point, we may want to combine all of this into a System.Net.Mail contract, but for now I've left it in a System.Net.Mime one.
Commit migrated from https://github.com/dotnet/corefx/commit/9594452b79f80f1262c6586ff8f2f5c21fb18ee2
The latest Windows 10 preview builds contain enough functionality in Ubuntu/Bash on Windows (a.k.a. Windows Subsystem for Linux, or WSL) that .NET Core mostly works now. With the fix for dotnet/corefx#11058, we can even build/test the CoreFx tree in this environment. Currently there are a few test failures; I've been working on identifying the causes of these, and filing bugs in the appropriate repos.
This change implements workarounds for all of the current known issues in the "inner loop" tests. Mostly, I've just conditionally disabled tests when running in the WSL environment.
There is still an issue, under investigation, causing non-deterministic failures in the System.Net.Http tests (Microsoft/BashOnWindowsdotnet/corefx#1068). And I haven't tried OuterLoop runs of anything but the networking tests.
Commit migrated from https://github.com/dotnet/corefx/commit/d9aa92f6616d851256339318aadb89a6737e6d13
WinHTTP returns an error from WinHttpQueryAuthSchemes if a server sends back a response with a scheme that isn't handled by WinHTTP. Many servers use custom auth schemes. A few don't even send a `WWW-Authenticate` header in the response at all (technically against RFC7235). To handle these cases and to match Desktop behavior, we ignore the error from WinHttpQueryAuthSchemes.
Fixesdotnet/corefx#11452 and dotnet/corefx#11456.
Commit migrated from https://github.com/dotnet/corefx/commit/ff50e500356f94c566baef786cc23e78cee870fd
We were getting an error "The parameter is incorrect" from WinHTTP when we tried to invoke default credential handling even for cases where the server doesn't use Negotiate or NTLM. Negotiate and NTLM are the only schemes that can use default credentials since they need to be transmitted via a challenge-response mechanism.
The fix here is to only set WinHTTP default credentials handling for Negotiate or NTLM schemes. Otherwise, it should behave as-if there were no credentials set.
Fixesdotnet/corefx#11266
Commit migrated from https://github.com/dotnet/corefx/commit/f48eb3480c51dd5b08fe6089c8d7a5041019d1e8
Lately, the CI system and test server infrastructure has been overloaded with many PRs. This is causing many networking tests to randomly fail due to resource exhaustion caused by so many simultaneous PR runs on the same CI machines. This occurrs not only when using an external test server endpoint (corefx-net.cloudapp.net) but also loopback servers.
To improve engineering efficiency for the team, we are moving most of the tests in the networking libraries from the default CI runs (innerloop). For developers working on networking libraries, the networking tests can be run by invoking the "outerloop" tests.
We will not be allowing any merges of PRs in the networking libraries unless the outerloop tests are also run by the developer.
This affects tests in the following libraries right now:
* System.Net.Http
* System.Net.Http.WinHttpHandler
* System.Net.Sockets
* System.Net.Security
* System.Net.WebSockets.Client
I will be working on fine tuning these exclusions (issue dotnet/corefx#11345) to try to bring back tests into the innerloop runs when we have begun to address the infrastructure issues.
Commit migrated from https://github.com/dotnet/corefx/commit/defbb8afd11b317f6b5cc2f4422a03d701b6dba3