Create Self-Signed Certificate
Create Key With Openssl
This example is using openssl
command on Ubuntu. If you are using Windows then you can use alternative tools, such as:
Install Cmder | Console Emulator that support for
openssl
commands.
To generate the key we will be using openssl on Ubuntu. We start firt by generating the private key myapp.key
and public certificate myapp.crt
:
We name .key and .crt to follow the convention used in ssl for certificates which can be found under /etc/ssl/(private|certs). Next we combine them into a key myapp.pfx usable by dotnet:
The resulting myapp.pfx
is the file which can be used to instantiate a X509Certificate2 object we needed.
If we already have a .pfx
and want to extract the private key myapp.key
and public key myapp.crt
:
Selfsigned certificate for local SSL usage
Just like how we created a key to be used for signing credentials, it is possible to use openssl to create selfsigned certificate to be used for SSL.
Simple steps to create self-signed certificate
Using commands below to generate private.key
, .csr
, self-signed-crt
, keyStore.pfx
, certificate.pem
Reference
Last updated