C# Windows上的VPS中的wss websocket中的证书失败。(TLS握手错误)
我们在Azure中有一个VPS,我正在使用websocket sharp创建一个服务器。我需要从web https连接,所以我需要安全连接wss,我创建了一个个人测试证书,并将其导出到“.cer”,它是我在项目的/bin/debug/theCertificate.cer路径的web套接字中添加的。我补充如下:C# Windows上的VPS中的wss websocket中的证书失败。(TLS握手错误),c#,azure,ssl,websocket,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 X509Cert
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,以及@vtorola所评论的内容。谢谢,祝你好运
wssv.SslConfiguration.EnabledSslProtocols
HTTPS和WSS是否使用相同的证书?嗨@vtortola,是的,证书不同,当使用相同的证书时,解决了另一个错误:
失败:WebSocket打开握手被取消
感谢您的建议。相同的证书用于HTTPS和WSS吗?嗨@vtortola,是的,证书不同,当使用相同的证书时,解决了另一个错误:失败:WebSocket打开握手被取消
感谢您的建议。