Skip to content

Instantly share code, notes, and snippets.

@meysampg
Created January 11, 2024 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meysampg/2af013d8a9b2b6f6e9e00c9d44fd885d to your computer and use it in GitHub Desktop.
Save meysampg/2af013d8a9b2b6f6e9e00c9d44fd885d to your computer and use it in GitHub Desktop.
Generate self-signed certificate which browser knows them
openssl genrsa -des3 -out rootCA.key 4096
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.crt
function genssl() {
openssl genrsa -out "$1.pg.key" 2048
openssl req -new -sha256 \
-key "$1.pg.key" \
-subj "/C=IR/ST=Tehran/O=MPG/OU=Chat/CN=$1.pg" \
-reqexts SAN \
-config <(cat /etc/ssl/openssl.cnf <(printf "\n[SAN]\nsubjectAltName=DNS:$1.pg")) \
-out "$1.pg.csr"
openssl x509 -req -extfile <(printf "subjectAltName=DNS:$1.pg") -days 1200 -in "$1.pg.csr" -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out "$1.pg.crt" -sha256
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment