Skip to content

Instantly share code, notes, and snippets.

@JParkinson1991
Created April 25, 2023 13:23
Show Gist options
  • Save JParkinson1991/3e455ec9d668dced63dae951a905d5d1 to your computer and use it in GitHub Desktop.
Save JParkinson1991/3e455ec9d668dced63dae951a905d5d1 to your computer and use it in GitHub Desktop.
Generation X509 Self Signed Certificates
# Generates X509 self signed keys pairs
#
# Structure:
# openssl req -x509 -newkey rsa:4096 -keyout "<pkey_name>" -out "<cert_name>" -sha256 -days <days> -subj '/CN=<domain>'
#
# Parmaeters:
# pkey_name: The name of the generated private key file
# cert_name: The name of the generated public key file
# days: The number of days the cert if valid for
# domain: The domain the cert is being generated on
#
# Variants
# Add '-nodes' to create certificates without a passphrase
# Remove "-subj '/CN=<domain>'" for interactive creation
# Example: localhost - no pass phrase - non-interactive - valid for 365 days
openssl req -x509 -newkey rsa:4096 -keyout "key.pem" -out "cert.pem" -sha256 -days 365 -subj '/CN=localhost' -nodes
# Example: localhost - with pass phrase - non-interactive - valid for 365 days
openssl req -x509 -newkey rsa:4096 -keyout "key.pem" -out "cert.pem" -sha256 -days 365 -subj '/CN=localhost'
# Example: localhost - with pass phrase - fully interactive - valid for 365 days
openssl req -x509 -newkey rsa:4096 -keyout "key.pem" -out "cert.pem" -sha256 -days 36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment