Created
April 7, 2015 16:15
-
-
Save thbkrkr/aa16435cb6c183e55a33 to your computer and use it in GitHub Desktop.
Generate Self-Signed SSL Certificate without prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate a passphrase | |
openssl rand -base64 48 > passphrase.txt | |
# Generate a Private Key | |
openssl genrsa -aes128 -passout file:passphrase.txt -out server.key 2048 | |
# Generate a CSR (Certificate Signing Request) | |
openssl req -new -passin file:passphrase.txt -key server.key -out server.csr \ | |
-subj "/C=FR/O=krkr/OU=Domain Control Validated/CN=*.krkr.io" | |
# Remove Passphrase from Key | |
cp server.key server.key.org | |
openssl rsa -in server.key.org -passin file:passphrase.txt -out server.key | |
# Generating a Self-Signed Certificate for 100 years | |
openssl x509 -req -days 36500 -in server.csr -signkey server.key -out server.crt | |
mv server.crt ssl.crt | |
mv server.key ssl.key |
Works in one single command for me:
openssl req -x509 -newkey rsa:4096 -nodes -out server.crt -keyout server.key -days 365 -subj "/C=FR/O=krkr/OU=Domain Control Validated/CN=*.krkr.io"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very nice code, life saving!
Please mention, that to use with mini_httpd (if you need to display small amount of static pages — it's great solution) you need to do this after: