8

In my company we have a Windows service developed in C# to process requests messages from clients using SSLStream with Tls12 and Server and Client certificates. Service have worked fine on Windows Server 2012, including Windows 10 PC, no matter if it's executed in release mode or debug to check code, however recently an exception is thrown when AuthenticateAsServer is executed. A piece of code is:

ServicePointManager.SecurityProtocol = SslProtocols.Tls12;
SslStream secureClient = new SslStream(networkStream, false);
secureClient.AuthenticateAsServer(serverCertificate);

networkStream is an instance of NetworkStream that has IP and port of the service. serverCertificate is a X509Certificate2 installed in local machine store acting as self-signed. Client has same certificate. The exception details is as follows:

System.Security.Authentication.AuthenticationException
  HResult=-2146233087
  Message=A call to SSPI failed, see inner exception.
  Source=System
  StackTrace:
       at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
       at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
       at System.Net.Security.SslStream.AuthenticateAsServer(X509Certificate serverCertificate)
       at TransakcioClassLib.ServiceStream..ctor(Int64 id, NetworkStream networkStream, Boolean isSecure, X509Certificate2 serverCertificate) in c:\Developer\OmniPay\0-Development\OmniGateway\TransakcioClassLib\TransakcioClassLib\TransakcioClassLib.cs:line 6311
       at TransakcioClassLib.TransakcioServer.ProcessClientRequestBlocking() in c:\Developer\OmniPay\0-Development\OmniGateway\TransakcioClassLib\TransakcioClassLib\TransakcioClassLib.cs:line 2658
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.ComponentModel.Win32Exception
       HResult=-2147467259
       Message=The function requested is not supported
       ErrorCode=-2147467259
       NativeErrorCode=-2146893054
       InnerException: 

As I mentioned before, service have been working fine until no much days ago. Any helps would be appreciate so much.

Aldemar Cuartas Carvajal
  • 1,573
  • 3
  • 20
  • 39

0 Answers0