Created
January 11, 2024 16:01
-
-
Save meysampg/2af013d8a9b2b6f6e9e00c9d44fd885d to your computer and use it in GitHub Desktop.
Generate self-signed certificate which browser knows them
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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