我目前正在尝试将SSL添加到我正在处理的项目中,因此我检查了MSDN以获取SSL流示例服务器。 https://docs.microsoft.com/en-us/dotnet/api/system.net.security.sslstream我已经运行它并且它运行但是当客户端连接它时会抛出此错误
Unhandled Exception: System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The client stopped the handshake.
at Mono.Security.Protocol.Tls.SslServerStream.OnNegotiateHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
发生了什么事?另外,为什么它只需要证书而不是私钥文件? SSL就是这样不起作用的。
答案 0 :(得分:2)
私钥通过证书对象提供,请参阅X509Certificate2.PrivateKey
。如果您有证书文件和单独的私钥文件,我认为您必须手动加载私钥并将其分配给证书的PrivateKey
属性。