-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgencerts.sh
More file actions
executable file
·23 lines (18 loc) · 803 Bytes
/
Copy pathgencerts.sh
File metadata and controls
executable file
·23 lines (18 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# Generate the CA root
openssl genrsa -aes256 -out ca_key.pem 4096
openssl req -new -x509 -days 7300 -key ca_key.pem -sha256 \
-extensions v3_ca -out ca_cert.pem
# Generate the cpdlcd key & CSR
openssl genrsa -aes256 -out cpdlcd/cpdlcd_key.pem 4096 || exit 1
openssl req -sha256 -new -key cpdlcd/cpdlcd_key.pem -out csr.pem \
-config openssl.cnf -extensions v3_req || exit 1
# Sign the cpdlcd CSR
openssl x509 -sha256 -req -in csr.pem \
-CA ca_cert.pem -CAkey ca_key.pem -CAcreateserial \
-days 3650 -out cpdlcd/cpdlcd_cert.pem \
-extfile openssl.cnf -extensions v3_req || exit 1
# Verify the signed cert against the CA cert
openssl verify -CAfile ca_cert.pem cpdlcd/cpdlcd_cert.pem || exit 1
# Throw away the CSR and CA serial number file
rm -f csr.pem ca_cert.srl