linx-simulator2/createCerts.sh

24 lines
815 B
Bash
Raw Normal View History

2019-09-18 08:11:16 +00:00
#!/bin/sh
OPENSSL_PATH="/usr/bin" #default install path
#OPENSSL_PATH="/usr/local/ssl/bin" #workaround for dual openssl install
2019-09-18 08:11:16 +00:00
if test "$#" -ne 1; then
echo "Error: Wrong parameters --> You must provide the certificate name."
echo "Please use: ./createCerts.sh 18"
exit 1
fi
DAYS=$((10*365))
DN="/C=US/ST=Illinois/L=Chicago/O=Safemobile/OU=PKI"
ID=$1
CERTS_PATH=certs
#generate key pair
2023-03-28 20:04:56 +00:00
$OPENSSL_PATH/openssl genrsa -out "$CERTS_PATH/$ID-key.pem" 4096
2019-09-18 08:11:16 +00:00
#generate signing request
2023-03-28 20:04:56 +00:00
$OPENSSL_PATH/openssl req -new -key "$CERTS_PATH/$ID-key.pem" -subj "$DN/CN=$ID" -out "$CERTS_PATH/$ID-csr.pem"
2019-09-18 08:11:16 +00:00
#sign new cert
2023-03-28 20:04:56 +00:00
$OPENSSL_PATH/openssl x509 -req -days $DAYS -in "$CERTS_PATH/$ID-csr.pem" -CA "$CERTS_PATH/ca1-cert.pem" \
2019-09-18 08:11:16 +00:00
-CAkey "$CERTS_PATH/ca1-key.pem" -set_serial 500 -out "$CERTS_PATH/$ID-cert.pem"