Created
October 5, 2021 23:37
-
-
Save lapo-luchini/6f596a9287fe5100b9f26728f9163c1e to your computer and use it in GitHub Desktop.
A script to create a local CA for you zrepl installation. Uses elliptic curves and SANs to be compatible with latest go.
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/sh | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 FQDN" | |
exit 1 | |
fi | |
cd `dirname "$0"` | |
if [ ! -f ca.crt ]; then | |
openssl ecparam -genkey -name prime256v1 -out ca.key | |
openssl req -x509 -new -SHA256 -nodes -days 3652 -subj "/CN=Root CA/OU=zrepl/O=YourName/C=IT" -key ca.key -out ca.crt | |
fi | |
if [ ! -f "$1.key" ]; then | |
openssl ecparam -genkey -name prime256v1 -out "$1.key" | |
fi | |
printf "[SAN]\nsubjectAltName=DNS:$1\n" > "$1.san" | |
openssl req -new -SHA256 -nodes -subj "/CN=$1/OU=zrepl/O=YourName/C=IT" -key "$1.key" -out "$1.csr" | |
openssl x509 -req -SHA256 -days 3652 -extfile "$1.san" -extensions SAN -in "$1.csr" -CA ca.crt -CAkey ca.key -CAcreateserial -out "$1.crt" | |
rm ca.srl "$1.csr" "$1.san" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment