From d674c23a4877ac31dc77898390c1dc3d60f6f764 Mon Sep 17 00:00:00 2001 From: Caesar Chen Date: Fri, 20 Jul 2018 16:51:02 -0700 Subject: [PATCH] Add more logging for authentication failure (dotnet/corefx#31225) * add logging * address feedback * feedback 2 * change Info to Error Commit migrated from https://github.com/dotnet/corefx/commit/3ea1a8cf78073491f9532e36a738a7b8be44829a --- .../src/System/Net/Security/SecureChannel.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs b/src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs index f969d49..cfe0a16 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs @@ -738,8 +738,16 @@ namespace System.Net.Security } ProtocolToken token = new ProtocolToken(nextmsg, status); + if (NetEventSource.IsEnabled) + { + if (token.Failed) + { + NetEventSource.Error(this, $"Authentication failed. Status: {status.ToString()}, Exception message: {token.GetException().Message}"); + } + NetEventSource.Exit(this, token); + } return token; } @@ -760,9 +768,8 @@ namespace System.Net.Security --*/ private SecurityStatusPal GenerateToken(byte[] input, int offset, int count, ref byte[] output) { -#if TRACE_VERBOSE if (NetEventSource.IsEnabled) NetEventSource.Enter(this, $"_refreshCredentialNeeded = {_refreshCredentialNeeded}"); -#endif + if (offset < 0 || offset > (input == null ? 0 : input.Length)) { NetEventSource.Fail(this, "Argument 'offset' out of range."); @@ -873,6 +880,11 @@ namespace System.Net.Security byte[] alpnResult = SslStreamPal.GetNegotiatedApplicationProtocol(_securityContext); _negotiatedApplicationProtocol = alpnResult == null ? default : new SslApplicationProtocol(alpnResult, false); + if (NetEventSource.IsEnabled) + { + NetEventSource.Exit(this); + } + return status; } -- 2.7.4