Skip to content

Commit

Permalink
fix the script to generate self-signed certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
neevek committed Jun 8, 2024
1 parent 848abd7 commit c799a7a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions gen_cert_and_key.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ if [[ $domain = "" ]]; then
exit 1
fi

openssl_cnf=
platform=$(uname 2> /dev/null)

if [[ "$platform" = "Darwin" ]]; then
openssl_cnf="/System/Library/OpenSSL/openssl.cnf"
elif [[ "$platform" = "Linux" ]]; then
openssl_cnf="/etc/ssl/openssl.cnf"
else
echo "Not supported!"
exit 1
fi

openssl req \
-newkey rsa:2048 \
-x509 \
Expand All @@ -16,7 +28,7 @@ openssl req \
-subj /CN=$domain \
-reqexts SAN \
-extensions SAN \
-config <(cat /System/Library/OpenSSL/openssl.cnf \
<(printf '[SAN]\nsubjectAltName=DNS:localhost')) \
-config <(cat $openssl_cnf \
<(printf "[SAN]\nsubjectAltName=DNS:$domain")) \
-sha256 \
-days 3650

0 comments on commit c799a7a

Please sign in to comment.