Created
July 13, 2022 17:47
-
-
Save TeamDman/744f7e1f9c0c06c5f08b1618b23c3318 to your computer and use it in GitHub Desktop.
Create a self signed cert and authority
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=ME" ` | |
-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 = *.mydomain.ca | |
[ req_ext ] | |
subjectAltName = @alt_names | |
[ alt_names ] | |
DNS.1 = *.mydomain.ca | |
DNS.2 = *.dev.mydomain.ca | |
IP.1 = 555.55.55.555 | |
"@ > 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 = *.mydomain.ca | |
DNS.2 = *.dev.mydomain.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