Skip to content

Commit

Permalink
how to add certs with SAN. go1.15 onwards would not take CN
Browse files Browse the repository at this point in the history
  • Loading branch information
nsimariaj committed Feb 12, 2024
1 parent 6a409da commit 6fe6147
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
43 changes: 43 additions & 0 deletions docs/howto-certs-san/x.509-certs-with-san/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
all: ca-cert client-cert router-cert

ca-cert:
openssl genrsa -out ca/ca.key 4096
openssl req -x509 -new -key ca/ca.key \
-days 3650 -out ca/ca.crt \
-config ca/ca.cnf

client-cert:
openssl genrsa -out client/client.key 4096
openssl req -new -key client/client.key \
-out client/client.csr -config client/client.cnf
openssl x509 -req -days 365 -in client/client.csr \
-CA ca/ca.crt -CAkey ca/ca.key \
-CAcreateserial -out client/client.crt

router-cert:
openssl genrsa -out router/router.key 4096
openssl req -new -key router/router.key \
-out router/router.csr -config router/router.cnf
openssl x509 -req -days 365 -in router/router.csr \
-CA ca/ca.crt -CAkey ca/ca.key \
-CAcreateserial -out router/router.crt \
-extensions req_ext -extfile router/router.cnf
cat router/router.crt router/router.key > router/router.pem

read-ca-crt:
openssl x509 -text -noout -in ca/ca.crt

read-client-csr:
openssl req -noout -text -in client/client.csr

read-client-crt:
openssl x509 -text -noout -in client/client.crt

read-router-csr:
openssl req -noout -text -in router/router.csr

read-router-crt:
openssl x509 -text -noout -in router/router.crt

clean:
rm */*.crt */*.key */*.csr */*.srl */*.pem
10 changes: 10 additions & 0 deletions docs/howto-certs-san/x.509-certs-with-san/ca/ca.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[req]
distinguished_name = req_distinguished_name
prompt = no

[req_distinguished_name]
countryName = US
stateOrProvinceName = California
localityName = Sunnyvale
organizationalUnitName = Engineering
commonName = Self Signed Root CA
10 changes: 10 additions & 0 deletions docs/howto-certs-san/x.509-certs-with-san/client/client.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[req]
distinguished_name = req_distinguished_name
prompt = no

[req_distinguished_name]
countryName = US
stateOrProvinceName = California
localityName = Sunnyvale
organizationalUnitName = Engineering
commonName = client
19 changes: 19 additions & 0 deletions docs/howto-certs-san/x.509-certs-with-san/router/router.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[req]
distinguished_name = req_distinguished_name
req_extensions = req_ext
prompt = no

[req_distinguished_name]
countryName = US
stateOrProvinceName = California
localityName = Sunnyvale
organizationalUnitName = Engineering
commonName = router

[req_ext]
subjectAltName = @alt_names

[alt_names]
DNS.1 = router
DNS.2 = router.englab.juniper.net
DNS.3 = *.juniper.net

0 comments on commit 6fe6147

Please sign in to comment.