Windows 7 and Windows 2008 R2 support TLS 1.1 and 1.2, but for legacy reasons by default those protocols are not enabled when a developer elects to use the system default. However, in .NET Core 2.0 and earlier, HttpClientHandler would enable them, due to being a wrapper for WinHTTP, which enabled them. Both for compatibility and because we prefer those higher protocols whenever possible, SocketsHttpHandler also pretends they're part of the default when running on Win7/2008R2.
Commit migrated from https://github.com/dotnet/corefx/commit/0c7a1de0448c9dee76723d0bedd90f76c3436662
By default, .NET Core defaults to allowing TLSv1, TLSv1.1, and TLSv1.2. However, whereas .NET Framework allows a developer to opt-in to SSLv2/SSLv3, .NET Core currently blocks it. This means developers are unable to use .NET Core when they need to communicate with an endpoint they don't control and that's unfortunately limited to one of these protocols, which blocks adoption of .NET Core.
This commit stops blocking these protocols. They're still disabled by default, and compiling against them still results in a deprecation warning, but if a developer chooses to ignore the warning and explicitly sets SslProtocols, they are at least able to use the protocols, subject to whatever the underlying operating system allows (e.g. Windows stops supporting SSLv2 as of v1607).
Commit migrated from https://github.com/dotnet/corefx/commit/3cc6fda0c6abe76eea222c165ebdf816e83df564
- Renames ManagedHandler to SocketsHttpHandler
- Moves a bunch of files around accordingly
- Updates System.Net.WebSockets.Client to use SocketsHttpHandler directly
- Updates System.Net.Http's tests with a reflection-based rather than TLS-based method for instantiating an HttpClientHandler backed by a SocketsHttpHandler.
Commit migrated from https://github.com/dotnet/corefx/commit/852d40e723c849e8d0c486676d40332343e12ca5
* Fix HttpClientHandler UAP to use a filtered set of client certs
My earlier PR dotnet/corefx#22022 refactored the GetEligibleClientCertificates code
into a Common method. However, I neglected to actually use it in the UAP
HttpClientHandler!
Fixed the handler to properly filter down the set of client
certificates.
Added new tests to verify functionality. While doing this, I discovered
that the tests need to run in an isolated process due to the per-process
caching behavior of the UAP HTTP stack.
So, I used the RemoteInvoke method. I had to duplicate some of the new
tests using Fact instead of using Theory. This is because the
RemoteInvoke doesn't allow non-string parameters and I had to pass
in X509Certificate2 objects. So, I separated out each variant into its
own Fact test.
* Address PR feedback
* Fix code refactoring to properly filter client certificates.
* Fix test names in nameof() blocks.
* Disable a test from using the managed handler.
* Address PR feedback
* Remove unneeded using statements.
* Disable managed handler in some SslProtocols tests.
Commit migrated from https://github.com/dotnet/corefx/commit/9c4af2973699aea35ce5c60c00f7dd14398e7a14
Due to platform differences on UAP and the current use of WinRT APIs to
implement that HTTP stack, a few properties won't have the same defaults
or behavior.
CheckCertificateRevocationList default value is true for UAP and can't
be changed. However, on UAP, revocation checking that results in an
indeterminate status (i.e. revocation server offline) is treated the
same as a valid result. This is the behavior of the underlying WinRT
APIs.
SslProtocols default value is SslProtocols.None which is the same as the
rest of .NET Core. 'None' means to use the system default. However, changes
to this property value will be ignored.
Similar to the decision made in PR dotnet/corefx#21403, we don't throw PNSE for these
differences. Instead we just no-op on the property setter.
The behavior differences will be documented in:
https://github.com/dotnet/corefx/wiki/ApiCompat
Contributes to dotnet/corefx#18116.
Commit migrated from https://github.com/dotnet/corefx/commit/711f785f072c8131b9d49792eeab02d2d55be662
Got the Http Functional tests running with no errors against NETFX (Desktop). Found a bunch
of compatibility differences between Desktop and Core that need to be investigated. For now,
the tests are skipped on Desktop.
Fixed the LoopbackServer so that it will run. It was blowing up with `MissingTypeException`
due to missing SocketTaskExtensions class (dotnet/corefx#17690).
Contributes to dotnet/corefx#17691
Commit migrated from https://github.com/dotnet/corefx/commit/b7f6f5f159ebe6c0597578bbd858697a6159a22f
There are ~4000 occurrences in corefx of "static readonly". There are ~200 occurrences of corefx of "readonly static". Replacing all of the straggler "readonly static" cases with "static readonly" to make things consistent.
Commit migrated from https://github.com/dotnet/corefx/commit/d9d1e815ad6c642cf5d61afa4a16726548598bb2
libcurl prior to v7.39 allows SSLv3 by default. Since we've switched our defaults to accepting whatever the platform defaults are, this commit disables our SSLv3-disabled-by-default test on libcurl versions earlier than 7.39.
Commit migrated from https://github.com/dotnet/corefx/commit/460503134b4995c997b46f2439f6704eb1951f1c
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
Modified the test LoopbackServer so that it can return the received data in the helper methods. This allows more use of the
simple ReadRequestAndSendResponseAsync() method instead of having to use the more complex methods.
Modified a few HttpClient tests to take advantage of this. More tests will be simplified in future PRs.
Commit migrated from https://github.com/dotnet/corefx/commit/14c8ddd89be1fac31a472efdcaee184ba9d62e58
We have several innerloop tests that make HTTP calls during System.Net.Http.Functional.Tests out to www.ssllabs.com, which has SSL endpoints for different SSL protocols. This commit avoids using that server during innerloop tests. The tests are moved to outerloop, and some replacements using a localhost are added to innerloop.
Commit migrated from https://github.com/dotnet/corefx/commit/8a9402b33d46166d1a3129a7c2cae0334b00c4b6
If an SSL operation fails, we call SSL_get_error to determine how to proceed.
SSL_get_error's logic is, essentially
libcrypto_error ?? WANT_READ ?? WANT_WRITE ?? WANT_X509 ?? panic
This means that if a previous call into libcrypto on the same thread had left
something in the error queue when the operation goes into the WANT_READ state (etc)
SSL_get_error will report that the request must have failed due to something in
libcrypto.
There are two different fixes being done here:
1) PKCS12_parse is a known contributor to this problem, clear out the queue on a
successful exit.
2) Before any SSL stream operation (handshake, read, write, shutdown) clear the
queue, in case there are other functions which are leaving dangling errors.
With those mitigations in place, the intermittent errors seen during SslStream
usage should hopefully be a thing of the past.
Commit migrated from https://github.com/dotnet/corefx/commit/80a53ed415ece115d15bcf519e81e600362fd3dc
We currently make a lot of calls off-box in our unit tests. By adding SSL support to the loopback server, we should be able to convert many more tests to avoid needing to actually hit the network. This adds such basic support, and converts a few tests to use it.
Also, since I was moving the certificate configuration code to a central location, I fixed an issue related to cleanup.
Commit migrated from https://github.com/dotnet/corefx/commit/b90795e1d5d7e8d8c68b9ca23d53b1ba0e392f46
Add CurlHandlers.SslProtocols option
With libcurl on the OpenSSL backend (the recommended configuration), we can provide full-fidelity for this option. With libcurl on another SSL backend, we can allow choosing all three TLS protcols or just one TLS protocol, but we can't support selecting two of the three.
Commit migrated from https://github.com/dotnet/corefx/commit/bd79e80f25923e0f2e29e07aba60b03070596bb4