Configuring an ssl server with a signed certificate

I am trying to create a simple server that listens on a port and authenticates with ssl. I have files

server.crt
server.key
my-ca.crt

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

Now I do not know how to load these three files in C #; I have something like

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

which does not work (I get

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

) but I don’t know how to add server.keyand / or my-ca.crt.

+5
source share
1 answer

X509Certificate2

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

PKCS12. . http://www.madboa.com/geek/openssl/#cert-pkcs12 http://www.openssl.org/docs/apps/pkcs12.html

+3

All Articles