[英]SslStream.AuthenticateAsServer exception - The server mode SSL must use a certificate with the associated private key
[英]SslStream.AuthenticateAsServer throws The server mode SSL must use a certificate with the associated private key
干杯,
我有一个带有 CERTIFICATE 部分和 PRIVATE KEY 部分的 *.crt 我加载此证书
X509Certificate2 serverCertificate = X509Certificate2.CreateFromCertFile("Data\\certificate.crt");
现在我想启动一个安全的 TcpListener,但得到
SslStream sslStream = new SslStream(client.GetStream(), false);
sslStream.AuthenticateAsServer(serverCertificate, clientCertificateRequired: true, checkCertificateRevocation: true);
错误“服务器模式 SSL 必须使用具有关联私钥的证书”...
有什么问题?
此答案适用于 C# .NET
对于 HTTPS 调用,该示例在 MSDN 上使用 TCP Listner 和 TCP Client 提供。
执行 sslStream.AuthenticateAsServer(serverCertificate, ..) 时,您应该加载 PFX 文件和密码,而不是 CER 文件,这样就不需要在客户端机器上注册。 如果有效,请告诉我在此之后我有问题:P
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.