-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenroll-cert
59 lines (46 loc) · 1.28 KB
/
enroll-cert
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
PASSWORD="A*Very*Bad*Passw8rd"
reqRoot() {
curl -o /etc/strongswan/ipsec.d/cacerts/root-ca.pem 'https://ejbca.example.com/ejbca/publicweb/webdist/certdist?cmd=cacert&issuer=CN%3DRootCA-RSA&level=0'
}
reqCA() {
if [ -f /etc/strongswan/ipsec.d/cacerts/caCert.der ]; then
rm /etc/strongswan/ipsec.d/cacerts/caCert.der
fi
strongswan scepclient \
--out cacert \
--caname VPN-CA-RSA \
--url https://ejbca.example.com/pkiclient.exe \
--method post \
--debug 1 \
}
reqCert() {
if [ -f /etc/strongswan/ipsec.d/reqs/myReq.der ]; then
rm -f /etc/strongswan/ipsec.d/reqs/myReq.der
fi
if [ -f /etc/strongswan/ipsec.d/private/myKey.der ]; then
rm -f /etc/strongswan/ipsec.d/private/myKey.der
fi
strongswan scepclient \
--out pkcs1 \
--out pkcs7 \
--out cert \
--keylength=2048 \
--algorithm enc=aes256 \
--algorithm dgst=sha256 \
--algorithm sig=sha256 \
--dn "cn=vpn.example.com" \
--subjectAltName "dns=vpn.example.com" \
--password $PASSWORD \
--caname VPN-CA-RSA \
--url https://ejbca.example.com/pkiclient.exe \
--method post \
--debug 1 \
}
cleanUp() {
openssl x509 -inform der -outform pem -in /etc/strongswan/ipsec.d/cacerts/caCert.der -out /etc/strongswan/ipsec.d/cacerts/caCert.pem
rm -f /etc/strongswan/ipsec.d/cacerts/caCert.der
}
reqRoot
reqCA
reqCert