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.
source
share