diff options
author | Paulo Janotti <pauloja@microsoft.com> | 2018-04-10 06:37:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-10 06:37:41 +0300 |
commit | 14f5d53b9b9badd9402a9331b9f1b8cbd30b5c85 (patch) | |
tree | b877f8b24f0a155c04af544ba73f8b8e478bbb9e /src | |
parent | a2b9b13db3280c077a7b2f67b1a8a38594883ed6 (diff) |
Clear SSL error queue after SSL_shutdown calls (#28949)
Clear SSL error queue after SSL_shutdown calls when there is an error.
Diffstat (limited to 'src')
4 files changed, 19 insertions, 0 deletions
diff --git a/src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ERR.cs b/src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ERR.cs index 608af35f59..f8420a0848 100644 --- a/src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ERR.cs +++ b/src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ERR.cs @@ -12,6 +12,9 @@ internal static partial class Interop { internal static partial class Crypto { + [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ErrClearError")] + internal static extern ulong ErrClearError(); + [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_ErrGetError")] internal static extern ulong ErrGetError(); diff --git a/src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs b/src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs index 57f18a1e60..59d332038d 100644 --- a/src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs +++ b/src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs @@ -318,6 +318,12 @@ namespace Microsoft.Win32.SafeHandles // Do a bi-directional shutdown. retVal = Interop.Ssl.SslShutdown(handle); } + + if (retVal < 0) + { + // Clean up the errors + Interop.Crypto.ErrClearError(); + } } private SafeSslHandle() : base(IntPtr.Zero, true) diff --git a/src/Native/Unix/System.Security.Cryptography.Native/pal_err.cpp b/src/Native/Unix/System.Security.Cryptography.Native/pal_err.cpp index 8985bc9999..1d40d2f93a 100644 --- a/src/Native/Unix/System.Security.Cryptography.Native/pal_err.cpp +++ b/src/Native/Unix/System.Security.Cryptography.Native/pal_err.cpp @@ -5,6 +5,11 @@ #include "pal_err.h" #include "pal_utilities.h" +extern "C" void CryptoNative_ErrClearError() +{ + ERR_clear_error(); +} + extern "C" uint64_t CryptoNative_ErrGetError() { return ERR_get_error(); diff --git a/src/Native/Unix/System.Security.Cryptography.Native/pal_err.h b/src/Native/Unix/System.Security.Cryptography.Native/pal_err.h index 7ef05fce5d..a8a629c177 100644 --- a/src/Native/Unix/System.Security.Cryptography.Native/pal_err.h +++ b/src/Native/Unix/System.Security.Cryptography.Native/pal_err.h @@ -6,6 +6,11 @@ #include "opensslshim.h" /* +Shims the ERR_clear_error method. +*/ +extern "C" void CryptoNative_ErrClearError(); + +/* Shims the ERR_get_error method. */ extern "C" uint64_t CryptoNative_ErrGetError(); |