在Windows上的VPS中,wss websocket中的证书失败。 (TLS握手错误)

时间:2016-11-24 01:15:40

标签: c# azure ssl websocket

我们在Azure中有一个VPS,我正在使用websocket-sharp来创建服务器。我需要从web https连接所以我需要安全连接wss,我创建了一个个人测试证书,我已将其导出到“.cer”,我在项目的/bin/debug/theCertificate.cer路径中的web套接字上添加了它。我按如下方式添加:

var wssv = new HttpServer(46443, true);
wssv.SslConfiguration.ServerCertificate = new X509Certificate2(myPath + "/theCertificate.cer", "password");

在本地服务器中正常工作但在放入VPS时显示此错误:

PM|Fatal|WebSocket.connect|WebSocketSharp.WebSocketException: An error has occurred during a TLS handshake. 
  ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream. 
  at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) 
  at Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.CheckCompletionBe 
  foreNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) 
  at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) 
  at System.Net.Security.SslState.ForceAuthenticati on(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) 
  at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) 
  at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtoco ls enabledSslProtocols, Boolean checkCertificateRevocation) at WebSocketSharp.WebSocket.setClientStream()
  --- End of inner exception stack trace ---
  at WebSocketSharp.WebSocket.setClientStream()
  at WebSocketSharp.WebSocket.doHandshake()
  at WebSocketSharp.WebSocket.connect()

知道为什么会这样吗?

感谢。

解决方案: 问题是我们需要启用SslProtocols,以及@vtortola评论的内容。谢谢,祝你好运。

wssv.SslConfiguration.EnabledSslProtocols

0 个答案:

没有答案