2019-05-26 00:12:10 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Check for openssl
|
|
|
|
command -v openssl >/dev/null 2>&1 || { echo >&2 "openssl required but not found. Aborting."; exit 1; }
|
|
|
|
|
2019-07-05 19:23:40 +02:00
|
|
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
2019-05-26 00:12:10 +02:00
|
|
|
# Remove any existing key files
|
2019-07-05 19:23:40 +02:00
|
|
|
[ ! -e "$DIR/cert.pem" ] || rm "$DIR/cert.pem"
|
|
|
|
[ ! -e "$DIR/key.pem" ] || rm "$DIR/key.pem"
|
|
|
|
[ ! -e "$DIR/cert.cert" ] || rm "$DIR/cert.cert"
|
|
|
|
[ ! -e "$DIR/cert.pfx" ] || rm "$DIR/cert.pfx"
|
2019-05-26 00:12:10 +02:00
|
|
|
|
|
|
|
# Generate new keys
|
2019-07-05 19:23:40 +02:00
|
|
|
openssl req -x509 -newkey rsa:4096 -keyout "$DIR/key.pem" -out "$DIR/cert.cert" -days 36500 -subj '/CN=www.mydom.com/O=My Company Name LTD./C=US' -outform DER -passout pass:test
|
|
|
|
openssl x509 -inform DER -in "$DIR/cert.cert" -out "$DIR/cert.pem"
|
|
|
|
openssl pkcs12 -export -out "$DIR/cert.pfx" -inkey "$DIR/key.pem" -in "$DIR/cert.pem" -passin pass:test -passout pass:test
|
2019-05-26 00:12:10 +02:00
|
|
|
|
|
|
|
ls
|