Last active
December 4, 2022 17:17
-
-
Save meros/d4f3554b2b704b67dffcd2bbcb790c1b to your computer and use it in GitHub Desktop.
Bash script to create valid root cert/web server cert for development purposes
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
#!/bin/bash | |
# Set the DNS name for the web certificate | |
DNS=app-192-168-10-74.nip.io | |
# Set the filename for the generated CA | |
CA=ca | |
# Generate the CA | |
openssl genrsa -out $CA.key 2048 | |
openssl req -subj "/C=SE/ST=NA/O=Acme, Inc./CN=$DNS" -days 365 \ | |
-key $CA.key -out $CA.pem -x509 -new -nodes -sha256 -out $CA.pem | |
# Generate the web certificate | |
openssl genrsa -out $DNS.key 2048 | |
openssl req -subj "/C=SE/ST=NA/O=Acme, Inc./CN=$DNS" -new -key $DNS.key -out $DNS.csr | |
openssl x509 -req -in $DNS.csr -CA $CA.pem -CAkey $CA.key -CAcreateserial \ | |
-out $DNS.crt -days 365 -sha256 -extfile <(printf "extendedKeyUsage = serverAuth \n subjectAltName=DNS:$DNS") | |
# Output success message and instructions on how to use the generated files | |
echo "Finished generating CA and web certificate" | |
echo "Install $CA.pem in iOs simulator and use $DNS.key & $DNS.crt as web server SSL certificates" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment