我已经看到了几个关于如何将PFX转换为证书文件的问题,但我需要采取另一种方式.
我有两个文件:
bob_cert.cert
bob_key.pem
我想将它们转换为单个.pfx文件.有没有这样做的工具?
我正在研究一些创建X509certificate和公钥/私钥对的代码.公钥被添加到证书中,并将其发送给签署它的CA.
然后通过System.Security.Cryptography.X509Certificates.X509Certificate2类访问返回的证书.现在,我想使用此证书启动与其他客户端的安全连接.因此我使用SslStream类.要启动SSL握手,我使用以下方法:
server.AssociatedSslStream.AuthenticateAsServer(
MyCertificate, // Client Certificate
true, // Require Certificate from connecting Peer
SslProtocols.Tls, // Use TLS 1.0
false // check Certificate revocation
);
Run Code Online (Sandbox Code Playgroud)
此方法要求私钥与证书关联.当然,CA返回的证书不包含私钥.但它作为.key文件存储在硬盘上.X509Certificate2类有一个名为PrivateKey的属性,我想将私钥与证书关联,但我找不到设置此属性的方法.
有没有办法可以将私钥与.net X509类关联起来?