Created
October 19, 2022 14:24
-
-
Save YooWaan/121c33874957fc77ae4546e6950c93c9 to your computer and use it in GitHub Desktop.
my-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
function gen() { | |
ca_subj=$1 | |
cert_subj=$2 | |
name=$3 | |
day=$4 | |
# create ca | |
openssl req -new -x509 -nodes -days ${day} -subj "/CN=$ca_subj" -keyout ${name}ca.key -out ${name}ca.crt | |
# private key | |
openssl genrsa -out ${name}.key | |
# certificate signing | |
openssl req -new -key ${name}.key -subj "/CN=$cert_subj" -out ${name}.csr | |
# | |
openssl x509 -req -in ${name}.csr -CA ${name}ca.crt -CAkey ${name}ca.key -CAcreateserial -days ${day} -out ${name}.crt | |
# confirm | |
openssl x509 -in ${name}.crt -text -noout | |
} | |
gen "$1" "$2" "$3" $4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment