diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-07-10 23:47:08 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-07-10 23:47:08 +0200 |
| commit | 64fd7ae0cd90db9053208a08703e20d8a05948cc (patch) | |
| tree | bb70e2ee03144ab492bf014fad497ee8b37eb2a3 /scripts | |
| parent | b8b8a7fab06ea146b3a2048f35a421b334a49918 (diff) | |
| download | greatoffice-64fd7ae0cd90db9053208a08703e20d8a05948cc.tar.xz greatoffice-64fd7ae0cd90db9053208a08703e20d8a05948cc.zip | |
feat: Add script to generate pfx for use in server
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/gen-cert.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/gen-cert.sh b/scripts/gen-cert.sh new file mode 100755 index 0000000..76ef232 --- /dev/null +++ b/scripts/gen-cert.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -Eeuo pipefail + +NAME=${1-""} +SUBJECT="/CN=greatoffice-dev-certs\/emailAddress=admin@greatoffice.life/C=NO" + +if [ -z "$NAME" ]; then + echo "Year is not specified, defaulting to current year" + NAME=$(date +%Y) +fi + +if [ -f "$NAME.pfx" ]; then + echo "$NAME.pfx exists, exiting" + exit 0 +fi +openssl genrsa -out $NAME.key +openssl req -nodes -new -subj $SUBJECT -in $NAME.key -out $NAME.csr +openssl req -nodes -x509 -subj $SUBJECT -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 +openssl x509 -req -days 365 -in $NAME.csr -signkey key.pem -out $NAME.crt +openssl pkcs12 -export -out $NAME.pfx -inkey key.pem -in $NAME.crt + +echo "Your cert is at $NAME.pfx" |
