-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-cert.sh
72 lines (61 loc) · 1.62 KB
/
make-cert.sh
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
set -e
mkdir -p server_certs
mkdir -p client_certs
echo Generating server certificate...
openssl req \
-newkey rsa:4096 \
-x509 \
-sha256 \
-addext "subjectAltName = DNS:localhost" \
-days 3650 \
-nodes \
-out server_certs/server.crt \
-subj "/C=CH/ST=Geneva/L=Geneva/O=Server/OU=Dept" \
-keyout server_certs/server.key
echo Generating client certificate...
# Generate Certificate Authority key
openssl genrsa \
-passout pass:test42 \
-des3 \
-out client_certs/ca.key 4096 \
# Generate Certificate Authority certificate
openssl req \
-passin pass:test42 \
-new \
-x509 \
-days 365 \
-key client_certs/ca.key \
-out client_certs/ca.crt \
-subj "/C=CH/ST=Geneva/L=Geneva/O=CertificateAuthority/OU=ExpertDepartment"
# Generating Client certificate key
openssl genrsa \
-passout pass:test42 \
-des3 \
-out client_certs/user.key 4096
# Generating Client certificate certificate
openssl req \
-passin pass:test42 \
-new \
-key client_certs/user.key \
-out client_certs/user.csr \
-subj "/C=CH/ST=Geneva/L=Geneva/O=UserOrg/OU=UserDepartment"
# Sign the certificate
openssl x509 \
-passin pass:test42 \
-req \
-days 365 \
-in client_certs/user.csr \
-CA client_certs/ca.crt \
-CAkey client_certs/ca.key \
-set_serial 01 \
-out client_certs/user.crt
# Generate a PKCS12 format certificate
openssl pkcs12 \
-passin pass:test42 \
-passout pass:test42 \
-export \
-out client_certs/user.p12 \
-inkey client_certs/user.key \
-in client_certs/user.crt \
-certfile client_certs/ca.crt