Skip to content

Instantly share code, notes, and snippets.

@anzz1
Last active September 5, 2025 21:54
Show Gist options
  • Select an option

  • Save anzz1/fdc3176b6f8ac194b73097f55853631d to your computer and use it in GitHub Desktop.

Select an option

Save anzz1/fdc3176b6f8ac194b73097f55853631d to your computer and use it in GitHub Desktop.
create_cert.sh
#!/bin/sh
# create CA certificate
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -sha256 -days 10950 -nodes -subj "/CN=www.example.com"
# create non-CA certificate (OpenSSL >=v1.1.1)
#openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -sha256 -days 10950 -nodes -subj "/CN=www.example.com" -addext "authorityKeyIdentifier=keyid" -addext "basicConstraints=CA:FALSE"
# create non-CA TLS certificate (OpenSSL >=v1.1.1)
#openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -sha256 -days 10950 -nodes -subj "/CN=www.example.com" -addext "authorityKeyIdentifier=keyid" -addext "basicConstraints=CA:FALSE" -addext "extendedKeyUsage=serverAuth" -addext "subjectAltName=DNS:www.example.com"
# create 1024-bit dhparams
#openssl dhparam -out dh1024.pem 1024
# print result
openssl x509 -noout -text -in cert.pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment