-
Notifications
You must be signed in to change notification settings - Fork 146
/
makeTestCerts.sh
executable file
·81 lines (67 loc) · 1.62 KB
/
makeTestCerts.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
73
74
75
76
77
78
79
80
81
#!/bin/bash
dest_dir=certs
if [ ! -d "$dest_dir" ]; then
mkdir "$dest_dir"
fi
if [ ! -d "$dest_dir" ]; then
echo "Unable to create directory: $dest_dir" >&2
exit 3
fi
cd "$dest_dir"
echo "Making CA key and certificate"
openssl req \
-new \
-x509 \
-days 3650 \
-extensions v3_ca \
-subj "/C=GB/ST=Scotland/L=Glasgow/O=Mosquitto-PHP/CN=Mosquitto-PHP Test CA" \
-keyout ca.key \
-out ca.crt \
-nodes
echo "Making server key"
openssl genrsa \
-out server.key \
2048
echo "Making server signing request"
openssl req \
-subj "/C=GB/ST=Scotland/L=Glasgow/O=Mosquitto-PHP/CN=localhost" \
-out server.csr \
-key server.key \
-new
echo "Signing server certificate"
openssl x509 \
-req \
-in server.csr \
-CA ca.crt \
-CAkey ca.key \
-CAcreateserial \
-out server.crt \
-days 3650
echo "Making encrypted client key"
openssl genrsa \
-out client-enc.key \
-des3 \
-passout pass:Mosquitto-PHP \
2048
echo "Making clear-text client key"
openssl rsa \
-in client-enc.key \
-passin pass:Mosquitto-PHP \
-out client.key
echo "Making client signing request"
openssl req \
-subj "/C=GB/ST=Scotland/L=Glasgow/O=Mosquitto-PHP/CN=Mosquitto-PHP Client" \
-out client.csr \
-key client.key \
-new
echo "Signing client certificate"
openssl x509 \
-req \
-in client.csr \
-CA ca.crt \
-CAkey ca.key \
-CAcreateserial \
-out client.crt \
-days 3650
echo "Created all certificates. Now run mosquitto with the following command line, from the current directory:"
echo "mosquitto -c mosquitto.conf -d"