在我的公司,我们有一个用 C# 开发的 Windows 服务,用于处理来自客户端的请求消息,使用 SSLStream 和 Tls12 以及服务器和客户端证书。服务在 Windows Server 2012 上运行良好,包括 Windows 10 PC,无论是在发布模式下执行还是调试检查代码,但是最近在执行 AuthenticateAsServer 时抛出异常。一段代码是:
ServicePointManager.SecurityProtocol = SslProtocols.Tls12;
SslStream secureClient = new SslStream(networkStream, false);
secureClient.AuthenticateAsServer(serverCertificate);
networkStream 是 NetworkStream 的一个实例,它具有服务的 IP 和端口。serverCertificate 是安装在本地机器存储中的 X509Certificate2,用作自签名。客户具有相同的证书。异常详情如下:
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:
正如我之前提到的,服务一直运行良好,直到不久前。任何帮助将不胜感激。