We removed the lifting from the lineup so tests should reference the
latest packages in order to ensure an implementation is available.
The latest pacakges exclude implementation dependencies so I needed to
add these to projects that were depending on them coming in transitively.
Commit migrated from https://github.com/dotnet/corefx/commit/bef9061fd1238adf47b864d8924d121e4134465b
Enabling NegotiateStream for Unix using native gssapi implementation.
The native libraries used are mit-krb5 on linux and the built-in GSS.Framework for OSX.
Also included are the tests which rely on configuring and deploying KDC on the host machine.
Commit migrated from https://github.com/dotnet/corefx/commit/facff9e8d04d9e7ddf53eabea365306266f48865
We'd disabled these tests on Linux because they were failing on OpenSUSE. The reason turned out to be that the openssl installed on OpenSUSE was built explicitly without null cipher support. This commit re-enables the tests, but as ConditionalFacts that check whether we're either on Windows or on a Unix with an openssl that sports null ciphers.
Commit migrated from https://github.com/dotnet/corefx/commit/28b0230bfbf8555a6af6993b7a86f639d4143f2e
Currently in SslStream, exceptions get captured and then later thrown with "throw exception;". This causes their stack traces to get overwritten, losing information about where the exception actually came from. This commit changes these locations to use ExceptionDispatchInfo instead, enabling the stacks and Watson bucket information to be preserved.
For example, instead of:
```
System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult) in corefx\src\System.Net.Security\src\System\Net\SecureProtocols\SslState.cs:line 752
at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result) in corefx\src\System.Net.Security\src\System\Net\SecureProtocols\SslState.cs:line 722
at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult) in corefx\src\System.Net.Security\src\System\Net\SecureProtocols\SslStream.cs:line 125
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xunit.Assert.<RecordExceptionAsync>d__61.MoveNext()
```
we now get:
```
System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) in corefx\src\System.Net.Security\src\System\Net\SecureProtocols\SslState.cs:line 882
at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest) in corefx\src\System.Net.Security\src\System\Net\SecureProtocols\SslState.cs:line 1110
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult) in corefx\src\System.Net.Security\src\System\Net\SecureProtocols\SslState.cs:line 752
at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result) in corefx\src\System.Net.Security\src\System\Net\SecureProtocols\SslState.cs:line 722
at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult) in corefx\src\System.Net.Security\src\System\Net\SecureProtocols\SslStream.cs:line 125
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xunit.Assert.<RecordExceptionAsync>d__61.MoveNext()
```
Commit migrated from https://github.com/dotnet/corefx/commit/be3b7c684d0cac65b02643821366eb596e658c65
The Interop.OpenSsl.Decrypt implementation is assuming that data to be decrypted will never have output larger than the input, but that's not a valid assumption, such as when compression is employed and the received data to be decrypted may get longer when decompressed. This is causing failures in SslStream on OS X, which appears to be using compression as part of the underlying OpenSSL implementation.
Commit migrated from https://github.com/dotnet/corefx/commit/3ddac0a769a6b7f21be550194ae15173bc9ff16a
Some fixes (adding imports, adding Platforms package) were tooled, but more complex ones (forking project.jsons, editing csproj's) were not.
Also makes dependency version validation rules case-insensitive. (I used this fix to update the versions of some packages.)
[tfs-changeset: 1573868]
Commit migrated from https://github.com/dotnet/corefx/commit/84af04317505d48feaa1e83dd5dc27ddc0f6de76
The property leaks through the abstraction. It's rarely used. And it complicates things on Unix due to exposing the underlying socket instance combined with difficulties with multiple connect calls on a single socket instance.
Until we have good reason to expose it in the contract, we're removing it from the contract before it's stable.
Commit migrated from https://github.com/dotnet/corefx/commit/30abd30421289509cd3bd18a9114501afdc0fb7c
In an application that's using the Redis client library, a significant portion of the allocations are coming from calls to ReadByte on an SslStream. Since SslStream doesn't override ReadByte, the base Stream.ReadByte is used, and it ends up allocating a temporary array to use in a call to Read.
This commit adds an override of ReadByte on SslStream that returns data from the stream's internal buffer if any is available, otherwise falling back to the old behavior.
On a test that repeatedly writes 1000 bytes and then reads each of those with ReadByte, allocations are reduced by 10x and throughput is doubled. (Note that removing the Interlocked.Exchange in ReadByte yields another 20% improvement in throughput, but I've left it in so as not to impact guarantees of the type.)
Commit migrated from https://github.com/dotnet/corefx/commit/b999431c9c519a797aff3eb472b614e0f15c6650
Pass the handle:
The Windows SslStream flow is to start a TLS session as server auth, then
process a CredentialsRequired during the handshake, add credentials to
the existing session, and continue.
It's hard to maintain symmetry on that flow for the Unix pathway, due to
the API differences in OpenSSL and SChannel. So, the Unix session will
always pass down to native the provided client auth credentials, and
OpenSSL can use them when it sees appropriate.
Untrusted certificates should still complete handshake:
The Unix SslStream implementation had two different places that a client
authentication certificate was validated. The first one was from an
OpenSSL callback, and reporting an error will interrupt the TLS handshake.
The second was from after the handshake, and presents the results to the
user validation callback to determine if data should be sent after the handshake.
In the ideal case the first version is redundant, in a user-handled case it caused
a failure when success was expected; so it should just be removed.
Enable the client authentication cert test for Unix:
Also asserts that the IsMutuallyAuthenticated property gets set, the certificates
used were the correct ones, and that both forward and callback versions of
providing the certificate function.
Commit migrated from https://github.com/dotnet/corefx/commit/908a129d5f32a6b5d2737d651445fdd38e1937ea