如何在。net中为SSL连接设置测试证书?

时间:2022-12-04 08:29:19

I would like to create an SSL connection for generic TCP communication. I think I figured out how to do it in the code, using the info here: http://msdn.microsoft.com/en-us/library/system.net.security.sslstream.aspx What I'm having trouble with is creating a cert so I can test this out. I tried makecert.exe testCert, and that created a cert, but apparently it doesn't have a private key associated with it. So what I'm looking for is the simplest procedure to create a cert and get the connection to work.

我想为通用的TCP通信创建一个SSL连接。我想我已经知道如何在代码中实现它了,使用这里的信息:http://msdn.microsoft.com/en-us/library/system.net.security.sslstream.aspx。我试着makecert。exe testCert,并创建了一个cert,但显然它没有与之关联的私钥。因此,我要寻找的是创建cert并使连接工作的最简单的过程。

3 个解决方案

#1


2  

I haven't found a simple way to do this yet, but I found this site helpful a few months back.

我还没有找到一个简单的方法来实现这一点,但是我发现这个网站几个月前很有用。

O'Reilly also published a book called Network Security Hacks (available on Safari) that has a section starting at Hack #45 on creating your own certificate authority.

O'Reilly还出版了一本名为《网络安全黑客(Safari)》的书,其中有一段从“Hack #45”开始创建自己的证书权威。

#2


1  

I asked a similar question referencing apache, but someone linked to a microsoft howto on the response. It may be helpful.

我问了一个类似的问题,引用apache,但有人链接到微软的回应。它可能是有益的。

Here

在这里

#3


0  

For anybody else attempting this the pkcs12 certificate created as detailed here openssl question and using the X509Certificate2.CreateFromCertFile method gets past the private key problem. Note I used openssl with cygwin on Windows.

对于任何尝试此方法的人,这里详细地创建了pkcs12证书,并使用X509Certificate2。CreateFromCertFile方法通过了私钥问题。注意,我在Windows上使用了openssl和cygwin。

#1


2  

I haven't found a simple way to do this yet, but I found this site helpful a few months back.

我还没有找到一个简单的方法来实现这一点,但是我发现这个网站几个月前很有用。

O'Reilly also published a book called Network Security Hacks (available on Safari) that has a section starting at Hack #45 on creating your own certificate authority.

O'Reilly还出版了一本名为《网络安全黑客(Safari)》的书,其中有一段从“Hack #45”开始创建自己的证书权威。

#2


1  

I asked a similar question referencing apache, but someone linked to a microsoft howto on the response. It may be helpful.

我问了一个类似的问题,引用apache,但有人链接到微软的回应。它可能是有益的。

Here

在这里

#3


0  

For anybody else attempting this the pkcs12 certificate created as detailed here openssl question and using the X509Certificate2.CreateFromCertFile method gets past the private key problem. Note I used openssl with cygwin on Windows.

对于任何尝试此方法的人,这里详细地创建了pkcs12证书,并使用X509Certificate2。CreateFromCertFile方法通过了私钥问题。注意,我在Windows上使用了openssl和cygwin。