Skip to content

Instantly share code, notes, and snippets.

@whiler
Created April 25, 2021 16:23
Show Gist options
  • Save whiler/6e850dad96b74039e08f2a1f8b5d8581 to your computer and use it in GitHub Desktop.
Save whiler/6e850dad96b74039e08f2a1f8b5d8581 to your computer and use it in GitHub Desktop.
generate the self-signed Certificate Authority and one certificate for localhost
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth,clientAuth
subjectAltName = @altnames
[altnames]
DNS.1 = localhost
DNS.2 = 127.0.0.1
DNS.3 = ::1
default: local.p12
RootCA.pem: RootCA.key
RootCA.key:
@echo generating local certificate authority
openssl req -x509 -nodes -new -sha256 -days 1024 -newkey rsa:2048 -keyout RootCA.key -out RootCA.pem
local.key: local.csr
local.csr:
@echo generating local certificate
openssl req -new -nodes -newkey rsa:2048 -keyout local.key -out $@
local.pem: local.key RootCA.pem extfile
openssl x509 -req -sha256 -days 1024 -in local.csr -CA RootCA.pem -CAkey RootCA.key -CAcreateserial -extfile extfile -out $@
local.p12: local.pem
openssl pkcs12 -export -inkey local.key -in local.pem -out $@
clean:
rm -f RootCA.* local.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment