In HttpClient on Unix when a client certificate is used, we add the intermediate certificates for the client authentication cert's chain so that the server can chain-verify. When we add the extra chain certificate to the SSL handle, we're transferring ownership to that handle, which we subequently dispose... but we don't mark the original SafeHandle as invalid, so it eventually gets finalized and we end up double-free'ing, leading to seg faults and other badness. This commit simply cleans up the handle appropriately.
Commit migrated from https://github.com/dotnet/corefx/commit/0b8dfc5774f66b8538e07813113d6c962a8d5775
When using a timeout and/or a cancellation token with a buffered HttpClient operation, the cancellation/timeout doesn't flow through to the actual read/write operations on the underlying streams. This means that on Windows, doing a basic operation like GetStringAsync with a server that pauses for arbitrarily long periods of time while sending the response body won't cancel or timeout until it sends more data. (We don't need to do this on Unix, as on Unix we already handle this case differently, with a single registration for the duration of the SendAsync operation.)
Commit migrated from https://github.com/dotnet/corefx/commit/cc8b48c8ea41b9cee888055483d16072f3f3a1c5
* Fix CurlHandler handling of redirects
- Relative urls in Location headers were not being handled correctly. We now allow any url that TryCreate will parse using the current url as a base.
- We were only handling a subset of redirect status codes as redirects, trying to second-guess which status codes libcurl would redirect for, e.g. 300 wasn't being treated as a redirect. We now let libcurl do all the work.
- We should have been playing it safer with regards to clearing out credentials if we weren't sure a Uri redirect location was valid. Now we do.
- We were tracking state unnecessarily that we should have instead been
asking libcurl for, e.g. the last url used in a redirect. This also caused us to store the wrong RequestMessage.Uri in some cases where a location header came in but we didn't actually follow it.
Commit migrated from https://github.com/dotnet/corefx/commit/7bd18d682f0e201275c988e6263239ab84f6389b
- Verify that request content isn't disposed until after response content is buffered
- Verify that request content isn't disposed until after request content is sent and response headers are received
- Verify that verbs which shouldn't send request content don't
Commit migrated from https://github.com/dotnet/corefx/commit/9c0eaa1b7a4812f50ac37f4adde516971d9b333a
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
Requires https://github.com/dotnet/buildtools/pull/751
This makes all the tests resolve using NETCoreApp1.0 instead of
DNXCore50. I've removed the netstandard1.6 import since that is no
longer needed. I've also removed the workarounds from tests that were
targeting netcoreapp1.0 on their own. For restore compat I've added an
DNXCore50 import to every test project. These can be removed once
test-runtime packages are updated to target NETCoreApp1.0.
I've updated all the test scripts which were assuming DNXCore50 as well
as docs which referred to this path.
Commit migrated from https://github.com/dotnet/corefx/commit/7ba4d296e3e0a2445ffa708c1e918d90d2bac69c
System.Net.Http:
Unix runtime was already special-case lifted to 1.4, now it's 1.6.
System.Net.Security:
Unix runtime was already special-case lifted to 1.4, now it's 1.6.
System.Security.Cryptography.X509Certificates:
Windows netcore50 and facades are unaffected.
Otherwise, for both Unix and Windows, the minimum runtime is now 1.6. Since netcoreapp1.0 is a 1.6 runtime, no problems are anticipated.
Commit migrated from https://github.com/dotnet/corefx/commit/ebb71ce79c79814304657e1ff7aa520d3a6d0ff2
Reading from the response stream using ReadAsync() was ignoring the cancellation token passed in. To fix this, registered a delegate that will be called to dispose the WinHTTP request handle during pending I/O. This will cause the WinHTTP operation to cancel.
Added tests. For now, left them disabled to be resolved in issue dotnet/corefx#8692 next week. But wanted to get this fix in asap since it blocks partners for RTM.
Fixesdotnet/corefx#8662.
Commit migrated from https://github.com/dotnet/corefx/commit/a6e019d8e1910b9fed3c1077be23bfd9023d2837
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
* Corefx does not pinvoke into libssl directly anymore. This commit moves the Interop files in $(COMMONPATH)\Interop\Unix\libssl to $(COMMONPATH)\Interop\Unix\System.Security.Cryptography.Native directory. Likewise, the SecuritySafeHandles are split across different files and are moved to $(COMMONPATH)\System\Net\Security\Unix.
Commit migrated from https://github.com/dotnet/corefx/commit/76eb58c3b60040ec7a32dcfd3593d67a27494dab