开发者

Setting up a ssl server socket with signed certificate

I'm trying to make a simple server which listens on a port and authenticates with ssl. I have files

server.crt
server.key
my-ca.crt

obtained with a openssl tutorial (http://www.vanemery.com/Linux/Apache/apache-SSL.html). my-ca.crt is my own CA certificate, server.crt contains the x509 server certificate (signed with my-ca.crt) and server.key is the corresponding private key.

I now don't know how to load these three files in开发者_如何学JAVA c#; I have something like

serverCertificate = new X509Certificate2("server.crt", "secret_password");
sslStream.AuthenticateAsServer(serverCertificate, false, SslProtocols.Tls, true);

which doesn't work (I get an

Unhandled Exception: System.NotSupportedException: The server mode SSL must use a certificate with the associated private key.

) but I have no clue how to add the server.key and/or my-ca.crt.


To use X509Certificate2 in the form

serverCertificate = new X509Certificate2("server.pfx", "secret_password");

you should save certificate in PKCS12 format. See http://www.madboa.com/geek/openssl/#cert-pkcs12 and http://www.openssl.org/docs/apps/pkcs12.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜