Created
July 6, 2022 16:08
-
-
Save TeamDman/8e310c15b1fe714c3d85658f1755d42b to your computer and use it in GitHub Desktop.
Creating a self signed cert with root 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
#!/bin/pwsh | |
openssl req -x509 ` | |
-sha256 ` | |
-days 365 ` | |
-newkey rsa:2048 ` | |
-subj "/CN=BEANS" ` | |
-keyout rootCA.key ` | |
-nodes ` | |
-out rootCA.crt | |
# -pass pass:beans ` | |
openssl genrsa -out server.key 2048 | |
@" | |
[ req ] | |
default_bits = 2048 | |
prompt = no | |
default_md = sha256 | |
req_extensions = req_ext | |
distinguished_name = dn | |
[ dn ] | |
CN = beans.ca | |
[ req_ext ] | |
subjectAltName = @alt_names | |
[ alt_names ] | |
DNS.1 = beans.ca | |
IP.1 = 111.11.11.11 | |
"@ > csr.conf | |
openssl req -new -key server.key -out server.csr -config csr.conf | |
@" | |
authorityKeyIdentifier=keyid,issuer | |
basicConstraints=CA:FALSE | |
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment | |
subjectAltName = @alt_names | |
[alt_names] | |
DNS.1 = beans.ca | |
"@ > cert.conf | |
openssl x509 -req ` | |
-in server.csr ` | |
-CA rootCA.crt ` | |
-CAkey rootCA.key ` | |
-CAcreateserial ` | |
-out server.crt ` | |
-days 365 ` | |
-sha256 ` | |
-extfile cert.conf | |
openssl pkcs12 ` | |
-inkey server.key ` | |
-in server.crt ` | |
-certfile rootCA.crt ` | |
-export ` | |
-out server.pfx ` | |
-password pass:beans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment