Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Creating a Self-Signed SSL Certificate

Create a secrets file:

touch ~/.secret

Make sure it looks like this:


And source it:

. ~/.secret
openssl genrsa -des3 -passout pass:$PASSPHRASE -out server.pass.key 2048;
openssl rsa -passin pass:$PASSPHRASE -in server.pass.key -out server.key;
openssl req -new -key server.key -out server.csr;
openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt;

# Remove the unencrypted private key
rm server.key

Test your generated and encrypted private key:

openssl rsa -in server.pass.key -text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.