If mkcert is not available, create certificates using openssl

This commit is contained in:
Sascha Wilde 2020-07-24 17:30:16 +02:00
parent 5d7dc56684
commit 9bcffb08fb

View File

@ -9,7 +9,19 @@ combined="src/combined.pem"
if [[ ! -f $combined ]]; then if [[ ! -f $combined ]]; then
echo "Creating certificates..." echo "Creating certificates..."
cd src cd src
if type 2>1 >/dev/null mkcert ; then
mkcert -cert-file localhost.pem -key-file localhost-key.pem localhost 127.0.0.1 mkcert -cert-file localhost.pem -key-file localhost-key.pem localhost 127.0.0.1
elif type 2>1 >/dev/null openssl ; then
echo "Command 'mkcert' not found, using openssl fallback."
echo "You will need to accept an security exception for the"
echo "generated certificate in your browser manually."
openssl req -x509 -newkey rsa:4096 -nodes -days 3650 \
-subj "/C=DE/O=Selfsigned Test/CN=localhost" \
-keyout localhost-key.pem -out localhost.pem
else
echo >&2 "FATAL: No valid certificate generation tool found!"
exit -1
fi
cat localhost.pem localhost-key.pem > combined.pem cat localhost.pem localhost-key.pem > combined.pem
echo "done" echo "done"
else else