Last active
October 14, 2015 15:13
-
-
Save rhenning/bde6c4e4051c8e87fa83 to your computer and use it in GitHub Desktop.
Quick CSR to Certificate with fake CA
This file contains 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
#!/usr/bin/env bash | |
set -e | |
if [[ "$#" != "1" ]]; then | |
echo usage: $0 /path/to/file.csr | |
exit 1 | |
fi | |
invoke_dir=$(pwd) | |
path_to_csr=$1 | |
ca_tempdir=$(mktemp -d -t csr2crt) | |
cd $ca_tempdir | |
openssl genrsa 2048 > ca.key | |
openssl req \ | |
-x509 \ | |
-new \ | |
-nodes \ | |
-key ca.key \ | |
-days 3650 \ | |
-subj '/C=US/ST=Pennsylvania/L=Philadelphia/O=WebLinc/CN=www.weblinc.com' \ | |
-out ca.crt | |
openssl x509 \ | |
-req \ | |
-in ${invoke_dir}/${path_to_csr} \ | |
-CA ca.crt \ | |
-CAkey ca.key \ | |
-CAcreateserial \ | |
-out ${invoke_dir}/site.crt \ | |
-days 365 | |
echo 'Wrote certificate to site.crt!' | |
rm -r $ca_tempdir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment