| 2 |
raymond |
1 |
#!/bin/bash
|
|
|
2 |
|
|
|
3 |
cat > ca_cert.conf << EOF
|
|
|
4 |
[ req ]
|
|
|
5 |
distinguished_name = req_distinguished_name
|
|
|
6 |
prompt = no
|
|
|
7 |
|
|
|
8 |
[ req_distinguished_name ]
|
|
|
9 |
O = Espressif Systems
|
|
|
10 |
EOF
|
|
|
11 |
|
|
|
12 |
openssl genrsa -out axTLS.ca_key.pem 2048
|
|
|
13 |
openssl req -new -config ./ca_cert.conf -key axTLS.ca_key.pem -out axTLS.ca_x509.req
|
|
|
14 |
openssl x509 -req -sha1 -days 5000 -signkey axTLS.ca_key.pem -CAkey axTLS.ca_key.pem -in axTLS.ca_x509.req -out axTLS.ca_x509.pem
|
|
|
15 |
|
|
|
16 |
cat > certs.conf << EOF
|
|
|
17 |
[ req ]
|
|
|
18 |
distinguished_name = req_distinguished_name
|
|
|
19 |
prompt = no
|
|
|
20 |
|
|
|
21 |
[ req_distinguished_name ]
|
|
|
22 |
O = axTLS on ESP8266
|
|
|
23 |
CN = esp8266.local
|
|
|
24 |
EOF
|
|
|
25 |
|
|
|
26 |
openssl genrsa -out axTLS.key_1024.pem 1024
|
|
|
27 |
openssl req -new -config ./certs.conf -key axTLS.key_1024.pem -out axTLS.x509_1024.req
|
|
|
28 |
openssl x509 -req -sha1 -CAcreateserial -days 5000 -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem -in axTLS.x509_1024.req -out axTLS.x509_1024.pem
|
|
|
29 |
|
|
|
30 |
openssl rsa -outform DER -in axTLS.key_1024.pem -out axTLS.key_1024
|
|
|
31 |
openssl x509 -outform DER -in axTLS.x509_1024.pem -out axTLS.x509_1024.cer
|
|
|
32 |
|
|
|
33 |
cat axTLS.key_1024 > server.key
|
|
|
34 |
cat axTLS.x509_1024.cer > server.cer
|
|
|
35 |
|
|
|
36 |
rm axTLS.* ca_cert.conf certs.conf
|