Skip to content

Instantly share code, notes, and snippets.

@itobey
Forked from bitoiu/self-signed-wildcard-cert-for-ghes.md
Last active May 29, 2021 09:51
Show Gist options
  • Save itobey/cfea294c5c592b0b6385f7077e94b9da to your computer and use it in GitHub Desktop.
Save itobey/cfea294c5c592b0b6385f7077e94b9da to your computer and use it in GitHub Desktop.
Self-Signed Wildcard certificate with SAN using openssl / SSL

Copy the default template of openssl.cnf to a writable location.

cp /usr/lib/ssl/openssl.cnf .

Uncomment the req_extensions = v3_req

req_extensions = v3_req # The extensions to add to a certificate request

Add subjectAltName to v3_req section

[ v3_req ]
 
# Extensions to add to a certificate request
 
basicConstraints = CA:TRUE # True if you want to use it on Android as well
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName = @alt_names

Add the main hostname and the wildcard to a new [alt_names] section (entire section probably has to be added)

[alt_names]
DNS.1 = nuc.local
DNS.2 = *.nuc.local

Run the following and fill all the essential information, especially the CN (Common Name):

openssl genrsa -out hostname.key 2048
openssl rsa -in hostname.key -out hostname-key.pem
openssl req -new -key hostname-key.pem -out hostname-request.csr
openssl x509 -req -extensions v3_req -days 365 -in hostname-request.csr -signkey hostname-key.pem -out hostname-cert.pem -extfile <path to openssl.conf>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment