linx-simulator2/createCerts.sh

23 lines
656 B
Bash
Raw Normal View History

2019-09-18 08:11:16 +00:00
#!/bin/sh
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
openssl genrsa -out "$CERTS_PATH/$ID-key.pem" 4096
#generate signing request
openssl req -new -key "$CERTS_PATH/$ID-key.pem" -subj "$DN/CN=$ID" -out "$CERTS_PATH/$ID-csr.pem"
#sign new cert
openssl x509 -req -days $DAYS -in "$CERTS_PATH/$ID-csr.pem" -CA "$CERTS_PATH/ca1-cert.pem" \
-CAkey "$CERTS_PATH/ca1-key.pem" -set_serial 500 -out "$CERTS_PATH/$ID-cert.pem"