Created
November 12, 2017 11:57
-
-
Save BeerOnBeard/7156511851c0b2ac3d1973e1b44a9611 to your computer and use it in GitHub Desktop.
Create self-signed certs using OpenSSL
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 | |
set -o nounset; | |
################################################################################# | |
# Script to generate a private key and pfx. | |
# Requires the variable $FileName to be set. | |
# Remember to `chmod +x makecert.sh` in order to run. | |
# Example: FileName=myfile ./makecert.sh | |
# This will generate myfile.key, myfile.csr, myfile.crt, and myfile.pfx | |
################################################################################# | |
echo "Generating private key."; echo; | |
openssl genrsa -out $FileName.key 2048; | |
echo; echo "Completed generating private key."; echo "Generating csr."; echo; | |
openssl req -new -days 365 -key $FileName.key -out $FileName.csr; | |
echo; echo "Completed generating csr"; echo "Generating crt."; echo; | |
openssl x509 -in $FileName.csr -out $FileName.crt -req -signkey $FileName.key -days 365; | |
echo; echo "Completed generating crt."; echo "Generating pfx."; echo; | |
openssl pkcs12 -export -out $FileName.pfx -inkey $FileName.key -in $FileName.crt; | |
echo; echo "Completed generating pfx."; echo; | |
echo "All done!"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment