diff options
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(); |