Last active
October 28, 2020 14:03
-
-
Save imZack/0c15be35d6c0d6621e00049c7ecf48ef to your computer and use it in GitHub Desktop.
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 | |
for i in {1..10}; | |
do | |
openssl req -x509 -new -sha256 -nodes \ | |
-out "cert-$i.der" \ | |
-outform DER \ | |
-newkey rsa:2048 \ | |
-keyout "cert-$i.key" \ | |
-config <( | |
cat <<-EOF | |
[req] | |
default_bits = 2048 | |
prompt = no | |
default_md = sha256 | |
req_extensions = req_ext | |
x509_extensions = v3_req | |
distinguished_name = dn | |
[ dn ] | |
C=TW | |
ST=TW | |
L=Xindian | |
O=Moxa | |
OU=Testing Domain | |
[email protected] | |
CN = cert-$i.test.com | |
[ req_ext ] | |
subjectAltName = @alt_names | |
[ alt_names ] | |
DNS.1 = test.com | |
DNS.2 = www.test.com | |
[ v3_req ] | |
authorityKeyIdentifier=keyid,issuer | |
basicConstraints=CA:FALSE | |
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment | |
EOF | |
) | |
openssl x509 -inform DER -outform PEM -in "cert-$i.der" -out "cert-$i.crt.pem" | |
cat "cert-$i.crt.pem" "cert-$i.key" > "cert-$i-with-privatekey.pem" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment