Skip to content

Instantly share code, notes, and snippets.

@erriapo
Created February 22, 2019 20:41
Show Gist options
  • Save erriapo/3211e6e08849d505ba83417cf9a3e261 to your computer and use it in GitHub Desktop.
Save erriapo/3211e6e08849d505ba83417cf9a3e261 to your computer and use it in GitHub Desktop.
Generate a self-signed TLS cert with subjectAltNames wildcards
$ cat openssl.cnf
[ req ]
default_bits = 2048
distinguished_name = req_distinguished_name
x509_extensions = v3_ca
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = CA
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = British Columbia
localityName = City
localityName_default = Vancouver
organizationName = Org
organizationName_default = Institution Green Inc
commonName = Common Name (e.g. server FQDN or YOUR name) # *.example.com
commonName_max = 64
emailAddress = Email Address
emailAddress_max = 64
[ v3_ca ]
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
basicConstraints = critical,CA:true
subjectAltName = @alt_names
[alt_names]
DNS.1 = *.example.com
DNS.2 = foo.example.com
DNS.3 = bar.example.com
DNS.4 = baz.example.com
$ openssl req -x509 -out ./cert.crt -newkey rsa:2048
-nodes -sha256 -days 1300 -keyout ./build/cert.key -config ./openssl.cnf
$ openssl x509 -in ./cert.crt -text -noout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment