The design of AuthenticateAsServerAsync has a clientCertificatesRequired flag. On Unix we were mapping that to "SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT", which causes OpenSSL to fail the handshake if no cert is provided. But the Windows code actually still allows this through, instead setting a policy error to indicate that no certificate was required. I'm simply removing the SSL_VERIFY_FAIL_IF_NO_PEER_CERT flag to match that design. I've also updated the test to assert that the error is actually being set.
Commit migrated from https://github.com/dotnet/corefx/commit/81f6c96f4f0562f1dfdf348f5ea9c126be28251e
The method sets a flag to indicate that an operation is in progress, then kicks off the operation, and then in a finally block potentially resets the flag. The intent of resetting it is to reset the flag iff the operation is no longer in progress, which would be the case if the operation was synchronous or if the initiation of the asynchronous operation resulted in an exception. As such, the finally block is checking whether the operation was synchronous or whether an exception has been captured.
However, for the exceptional case, this leads to race conditions. The initiation of the asynchronous operaiton can lead to the operation running concurrently with the remainder of the ProcessAuthentication method, namely concurrently with the finally block. If the operation starts quickly and fails quickly, it'll store the exception, which will cause the finally block to see that an exception has been captured and mistakenly believe that the operation failed synchronously, thus resetting the flag. But the operation was actually asynchronous, and when EndAuthentication is called, it'll see that the flag has been reset and think that the EndAuthentication call is erroneous, thus throwing an exception. While it should throw an exception (the one that caused the operation to fail), it ends up throwing an InvalidOperationException instead to signal that EndAuthentication was used incorrectly.
The fix is to move the check for the exceptional situation out of the finally and into a catch block. The catch block is then used to reset the flag only if an exception emerges synchronously, and the finally block is used to reset the flag only for synchronous operations. (It's possible that for synchronous operations that fail, the flag could be written as 0 twice... that's fine.)
This fixes the failure on both Windows and Unix. The failure wasn't reproing on Windows but only because of differences in timing... adding a brief pause at the end of the try block would trigger the failure on Windows as well.
Commit migrated from https://github.com/dotnet/corefx/commit/9e63a418f6ab0dc01ab9e51f2ad9d498a35899cd
It looks like a couple libraries were using
System.Security.Principal.Windows unintentionally in their
Unix implementations. @dagood discovered this when
trying to restore our tools-runtime project for unix RIDs.
This fix removes the dependencies from those libs
in the CoreFx repro.
/cc @CIPop @saurabh500
It looks like WCF also has this problem as well,
since it hasn't split System.Private.ServiceModel
into windows specific packages.
/cc @StephenBonikowsky
Commit migrated from https://github.com/dotnet/corefx/commit/6902316fed76f2a905ef626b7ef0a64b4749a237
Some more GlobalLog.IsEnabled guards. I noticed a few while doing some other profiling, and so did another set of searches across the whole codebase. Many of these came from the System.Net.Security PRs that were in-progress at the same time I was doing the previous logging changes.
Commit migrated from https://github.com/dotnet/corefx/commit/a04c9898b9bc6d06cd42e1dfd93a63633da4dd30
Substituting Logging calls to EventSource calls, or calls to
LoggingHash.
Formatting Changes
Fixing Aligment, and casing.
Changing Dump methods log the hash of the object calling it instead of the method
After some discussion, it was decided that it is more useful to log the
object where the dump happens, than the method. Doing the necessary
changes for it.
Changing usage of "this" to [CallerMemberName]
Instead of using this to know who called the logging method, using
[CallerMemberName] as an attribute to the parameter to fill that
information.
Adding a TODO item.
Making a note to not change NetEventSource or it can break.
Missing Underscore
Adding missing underscore in _wsaBuffer
Commit migrated from https://github.com/dotnet/corefx/commit/f39502ef910c90ba1e67d787df98b627d39ba6cc
In profiling a client/server scenario where the client launches a bunch of async operations against the server, close to 15% of all allocated instances on the client are for System.Threading.ExecutionContext (~9% of the allocated space). This didn't make sense, because on CoreCLR ExecutionContext is immutable and neither ExecutionContext.Capture() nor ExecutionContext.CreateCopy() should be allocating.
It turns out that some of the System.Net libraries had a custom System.Threading.ExecutionContext shim object with a comment in the file "Important: This is temporary code". Ugh.
I've removed it. No more ExecutionContext allocations. And using the right ExecutionContext object from CoreCLR.
This also shrinks the size of SocketAsyncEventArgs by another field, as a separate ExecutionContext copy no longer need be maintained, due to ExecutionContext immutability on platforms other than the full framework.
Commit migrated from https://github.com/dotnet/corefx/commit/241eb27504a4e7bc774e202acc5447b09bb4a2d6
- Remove dead Assert overloads that include a Boolean conditional
- Fix up several missed call sites. Missed primarily due to code being conditionally included based on different build flavors (e.g. Windows vs Unix)
- Fix up GlobalLog fakes to include IsEnabled
Commit migrated from https://github.com/dotnet/corefx/commit/cc8a5d162d36efc8bd56ba406efea71ee3a8af6f
This these .builds files were updated and generated from a script
based on the configurations defined in the matching csproj files.
This updates the builds files to specify OSGroup and TargetGroup
as metadata instead of using AdditionalProperties and also sorts them by
TargetGroup followed by OSGroup.
Commit migrated from https://github.com/dotnet/corefx/commit/95efe37475916016a5fc6ee6f0ba584d990c4196
This add a default configuration before the Import of dirs.props
for any projects that don't have Debug as the default configuration.
Removed Configuration and Platform properties set after dirs.props
as they would have no affect and just cause confusion.
Removed OutputType=Library property as it isn't necessary.
Commit migrated from https://github.com/dotnet/corefx/commit/9e1da13cf6d5ff4b37b1867beb3411a2fe61da6a
Adding EventSources to substitute the previous logging model using
TraceSources.
In this PR 4 event sources are added:
-NetEventSource
-SocketsEventSource
-HttpEventSource
-SecurityEventSource
Event methods for NetEventSource, SocketsEventSource and HttpEventSource
are
fully added. SecurityEventSource has only a few of
the new event methods implemented.
Changes in production code are done to match this new implementation.
(Only changes for
events in Sockets and Http are done in this iteration).
Adding missing reference to LoggingHash
Missing Reference in Security csproj
Missing reference in NetworkInformation
Adding a reference and adding a missing new line.
Adding references and readonly modifier.
Adding another missing reference.
Adding some missing blank lines and making readonly the s_log in the
EventSources.
Completing SecurityEventSource
Adding missing all the security events that will substitute PrintInfo
calls.
Doing changes in code to reflect this.
Transforming SecurityEventSource into a Partial class
Some of the events were Windows specific, because of the enums they were
using. Those events are now in a partial class that is included when
those enums are defined.
Moving events to partial SecurityEventSource class
Some more events using Interop.SecurityStatus are moved into the partial
windows specific class.
Also, a missed non event header is added for Associate method in
HttpEventSource.
Deleting Logging reference to instead use LoggingHash
Addressing some of the PR feedback
Adding the Issue number to TODO for localization, and using BlockCopy
instead of a Loop to copy array. Also, correctly passing partialBuffer
instead of Buffer to the DumpArrayAsync method.
Commit migrated from https://github.com/dotnet/corefx/commit/1cd8bf635d4b9a6d8a7d1e25cd320814c993f38b
This is the only place in all of corefx (outside of the X509Certificates tests) that instantiates an X509Certificate object (instead of an X509Certificate2).
Since the property still return an X509Certificate(1), the callers would have to cast it to use the X509Certificate2-only properties, but now an `as` will suffice, whereas before it required an up-converting operation.
Commit migrated from https://github.com/dotnet/corefx/commit/4db0e714272a195fc29d6f904ad6bb3422e94e43