The two files you need are the SSL certificate, private in PEM, and the private key. PEM encoded certificates and keys are Base64 encoded text with start and end separators that look like -----BEGIN RSA PRIVATE KEY----- or similar.
To create an SSL certificate, you first need to generate a private key and a certificate signing request or CSR (which also contains your public key). You can do this in various ways, but here, as in OpenSSL.
openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem
This will cause you to enter an interactive prompt to create a 2048-bit RSA and CSR secret key that has all the information you want to enter in the prompts. ( Note: The common name is where you want to place the domain name that you will use to access your site. ). As soon as you do this, you usually send this CSR to a trusted certificate and after they confirm your request, you will receive a certificate.
If you do not need a trusted certificate (usually for development purposes), you can simply create a self-signed certificate. To do this, we can use almost the same line, but we will pass two additional parameters.
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
This will give you a certificate (valid for 10 years) and a pair of keys that you can use in the published code snippet.
Paul Kehrer Oct. 16 2018-12-12T00: 00Z
source share