Created
August 12, 2019 15:30
-
-
Save MilyMilo/bca0a103e13cf21af93e16962c36c74d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USERNAME="test" | |
CA_CRT="./ca/server.crt" | |
CA_KEY="./ca/server.key" | |
TIME=$(date +%H_%M) | |
OUT="${TIME}_${USERNAME}/" | |
mkdir $OUT | |
SERIAL=$((1 + RANDOM % 50)) | |
KEY="${OUT}${USERNAME}_key.pem" | |
CSR="${OUT}${USERNAME}_csr.pem" | |
CRT="${OUT}${USERNAME}_cert.pem" | |
SUB="/CN=${USERNAME}" | |
P12="${OUT}${USERNAME}.p12" | |
openssl req -newkey rsa:2048 -keyout $KEY -out $CSR -nodes -days 365 -subj $SUB | |
openssl x509 -req -in $CSR -CA $CA_CRT -CAkey $CA_KEY -out $CRT -set_serial $SERIAL -days 365 | |
openssl pkcs12 -export -clcerts -in $CRT -inkey $KEY -passout pass: -out $P12 | |
mv -f $P12 . | |
rm -rf $OUT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment