C=US
CN=Example-Root-CA
SUBJ="/C=$C/CN=$CN"
openssl req -x509 -nodes -new -sha256 -days 1024 -newkey rsa:2048 -keyout ca.key -out ca.crt -subj "$SUBJ"
C=US
ST=California
L="San Diego"
O=ACME
CN=example.com
SUBJ="/C=$C/ST=$ST/L=$L/O=$O/CN=$CN"
openssl req -new -nodes -newkey rsa:2048 -keyout $CN.key -out $CN.csr -subj "$SUBJ"
CN=example.com
EXTFILE="
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = $CN
DNS.2 = *.$CN
"
openssl x509 -req -sha256 -days 1024 -in $CN.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out $CN.crt \
-extfile <( echo "$EXTFILE" )