简体   繁体   English

SslStream.AuthenticateAsServer 抛出服务器模式 SSL 必须使用具有关联私钥的证书

[英]SslStream.AuthenticateAsServer throws The server mode SSL must use a certificate with the associated private key

Cheers,干杯,

I have a *.crt with a CERTIFICATE section and a PRIVATE KEY section I load this certificate with我有一个带有 CERTIFICATE 部分和 PRIVATE KEY 部分的 *.crt 我加载此证书

X509Certificate2 serverCertificate = X509Certificate2.CreateFromCertFile("Data\\certificate.crt");

Now I want to start a secure TcpListener, but get at现在我想启动一个安全的 TcpListener,但得到

SslStream sslStream = new SslStream(client.GetStream(), false);
sslStream.AuthenticateAsServer(serverCertificate, clientCertificateRequired: true, checkCertificateRevocation: true);

the error "The server mode SSL must use a certificate with the associated private key"...错误“服务器模式 SSL 必须使用具有关联私钥的证书”...

Whats the problem?有什么问题?

This answer is for C# .NET此答案适用于 C# .NET

For HTTPS calls, the example is provided on MSDN using TCP Listner and TCP Client.对于 HTTPS 调用,该示例在 MSDN 上使用 TCP Listner 和 TCP Client 提供。

https://docs.microsoft.com/en-us/dotnet/api/system.net.security.sslstream?redirectedfrom=MSDN&view=netframework-4.7.2#Anchor_5 https://docs.microsoft.com/en-us/dotnet/api/system.net.security.sslstream?redirectedfrom=MSDN&view=netframework-4.7.2#Anchor_5

When doing sslStream.AuthenticateAsServer(serverCertificate, ..) you should load a PFX file along with password, instead of CER file, then it will not require registration on client machine.执行 sslStream.AuthenticateAsServer(serverCertificate, ..) 时,您应该加载 PFX 文件和密码,而不是 CER 文件,这样就不需要在客户端机器上注册。 if works please tell me i have problems after this :P如果有效,请告诉我在此之后我有问题:P

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SslStream.AuthenticateAsServer异常-服务器模式SSL必须使用带有关联私钥的证书 - SslStream.AuthenticateAsServer exception - The server mode SSL must use a certificate with the associated private key SslStream.AuthenticateAsServer证书链 - SslStream.AuthenticateAsServer certificate chain 如何为SslStream.AuthenticateAsServer()创建证书? - How to create certificate for SslStream.AuthenticateAsServer()? 服务器模式 SSL 必须使用具有关联私钥的证书 - 在 TLS 握手期间 - The server mode SSL must use a certificate with the associated private key - during TLS handshake 获取“服务器模式 SSL 必须使用具有关联私钥的证书。” X509Certificate2 中的错误由 use.cer 而不是.pfx - Get "The server mode SSL must use a certificate with the associated private key." error in X509Certificate2 by use .cer instead of .pfx SslStream.AuthenticateAsServer 挂起 - SslStream.AuthenticateAsServer hangs c#SSL TCPServer卡在SsLStream.AuthenticateAsServer() - c# SSL TCPServer stuck at SsLStream.AuthenticateAsServer() SslStream AuthenticateAsServer失败,并在Mono上出现“服务器证书私钥不可用。”异常 - SslStream AuthenticateAsServer failed with “Server certificate Private Key unavailable.” exception on Mono 在 C# 中,在服务器端使用 SslStream.AuthenticateAsServer() 有什么意义? - In C# what is the point of using SslStream.AuthenticateAsServer() on the server side? sslStream.AuthenticateAsServer忽略RemoteCertificateValidationCallback - sslStream.AuthenticateAsServer ignores RemoteCertificateValidationCallback
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM