Skip to content

Commit 7632145

Browse files
author
Patrick Böker
committed
Copy the cert gen script from cro-tls
I only just noticed there already is such a script. Just use that.
1 parent 0f1f8b1 commit 7632145

File tree

3 files changed

+40
-65
lines changed

3 files changed

+40
-65
lines changed

xt/certs-and-keys/my.conf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[req]
2+
default_bits = 4096
3+
prompt = no
4+
default_md = sha256
5+
req_extensions = req_ext
6+
distinguished_name = dn
7+
8+
[dn]
9+
C = CZ
10+
ST = Central Bohemia
11+
L = Prague
12+
O = CA
13+
OU = IT
14+
CN = localhost
15+
emailAddress = foo@example.net
16+
17+
[req_ext]
18+
subjectAltName = @alt_names
19+
20+
[alt_names]
21+
DNS.1 = localhost

xt/certs-and-keys/refresh.sh

Lines changed: 0 additions & 65 deletions
This file was deleted.

xt/certs-and-keys/tls.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
# Generate self signed root CA cert
4+
openssl req -days 365 -config my.conf -nodes -x509 -newkey rsa:4096 -keyout ca.key -out ca-crt.pem -subj "/C=CZ/ST=Central Bohemia/L=Prague/O=CA/OU=IT/CN=localhost/emailAddress=foo@example.net"
5+
6+
# Generate server cert to be signed
7+
openssl req -nodes -newkey rsa:4096 -keyout server-key.pem -out server.csr -subj "/C=CZ/ST=Central Bohemia/L=Prague/O=foo/OU=IT/CN=localhost/emailAddress=foo@example.net"
8+
9+
# Sign the server cert
10+
openssl x509 -req -days 365 -in server.csr -CA ca-crt.pem -CAkey ca.key -CAcreateserial -out server-crt.pem -extensions req_ext -extfile my.conf
11+
12+
# Clean up extra files
13+
rm ca-crt.srl ca.key server.csr
14+
15+
# Verify certs validate correctly
16+
echo "-----"
17+
echo "Verifying certs"
18+
openssl verify -CAfile ca-crt.pem ca-crt.pem
19+
openssl verify -CAfile ca-crt.pem server-crt.pem

0 commit comments

Comments
 (0)