简体   繁体   English

如何为SslStream.AuthenticateAsServer()创建证书?

[英]How to create certificate for SslStream.AuthenticateAsServer()?

I'm trying to write a server application that uses SSL to communicate. 我正在尝试编写一个使用SSL进行通信的服务器应用程序。 After accepting a connection, I believe I have to call SslStream.AuthenticateAsServer . 接受连接后,我相信我必须调用SslStream.AuthenticateAsServer However, this expects a certificate and I do not understand how to create one. 但是,这需要一个证书,我不知道如何创建证书。

I followed the advice given in the answer to this question : 我遵循了这个问题的答案中给出的建议:

I ran the following to create a server.pfx file: 我运行以下命令来创建server.pfx文件:

 makecert.exe -r -pe -n "CN=localhost" -sky exchange -sv server.pvk server.cer pvk2pfx -pvk server.pvk -spc server.cer -pfx server.pfx 

Then I loaded it in code with: 然后我将其加载到代码中:

 certificate = new X509Certificate2("server.pfx", "password"); 

However, I did that exactly, and I get a CryptographicException saying “The specified network password is not correct.”, which is patently false because I used the password x , which is very hard to mistype. 但是,我确实做到了这一点,并且得到了CryptographicException说“指定的网络密码不正确。”,这显然是错误的,因为我使用的密码x很难输入。 What am I doing wrong? 我究竟做错了什么?

暂无
暂无

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

相关问题 SslStream.AuthenticateAsServer证书链 - SslStream.AuthenticateAsServer certificate chain SslStream.AuthenticateAsServer 挂起 - SslStream.AuthenticateAsServer hangs sslStream.AuthenticateAsServer忽略RemoteCertificateValidationCallback - sslStream.AuthenticateAsServer ignores RemoteCertificateValidationCallback 为什么不支持在同一进程中使用同一证书调用 SslStream.AuthenticateAsServer 和 SslStream.AuthenticateAsClient? - Why is calling SslStream.AuthenticateAsServer and SslStream.AuthenticateAsClient with the same certificate in the same process not supported? 如何在不导入的情况下创建与 SslStream AuthenticateAsServer 一起使用的证书 - How to create a certificate to use with SslStream AuthenticateAsServer without importing SslStream.AuthenticateAsServer异常-服务器模式SSL必须使用带有关联私钥的证书 - SslStream.AuthenticateAsServer exception - The server mode SSL must use a certificate with the associated private key 从SQL加载时,SslStream.AuthenticateAsServer证书失败,但从嵌入式文件加载时,SslStream.AuthenticateAsServer证书有效 - SslStream.AuthenticateAsServer certificate fails when loaded from SQL, but works when loaded from an embedded file SslStream.AuthenticateAsServer 抛出服务器模式 SSL 必须使用具有关联私钥的证书 - SslStream.AuthenticateAsServer throws The server mode SSL must use a certificate with the associated private key 如何在SSLStream的AuthenticateAsServer()中提供证书链? - How to provide certificate chain in SSLStream's AuthenticateAsServer()? 为什么sslStream.AuthenticateAsServer不需要UAC和替代方法 - Why does sslStream.AuthenticateAsServer require no UAC and alternatives
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM