Skip to content

Instantly share code, notes, and snippets.

@YooWaan
Created October 19, 2022 14:24
Show Gist options
  • Save YooWaan/121c33874957fc77ae4546e6950c93c9 to your computer and use it in GitHub Desktop.
Save YooWaan/121c33874957fc77ae4546e6950c93c9 to your computer and use it in GitHub Desktop.
my-ca
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