mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-08-26 03:10:32 +08:00
feat(examples): Update openssl server/client example to use pem file directly
This commit is contained in:
@ -1,43 +1,29 @@
|
||||
1. Run ./gencrt.sh or if you have your own certificate, move to the openssl_client directory, the name is ca.crt,server.crt, server.key, client.crt and client.key.
|
||||
1. Run `./gencrt.sh` or if you have your own certifications, move them to the main directory, the name is ca.pem, server.pem, server.key, client.pem and client.key.
|
||||
|
||||
The server.crt and client.crt was generate by the same ca.crt in ./gencrt.sh.
|
||||
The server.pem and client.pem was generated by the same ca.pem in gencrt.sh.
|
||||
|
||||
Server side needs ca.crt(to verify client.crt), server.crt, server.key
|
||||
Server side needs ca.pem(to verify client.pem), server.pem, server.key
|
||||
|
||||
Client side needs ca.crt(to verify server.crt), client.crt, client.key
|
||||
Client side needs ca.pem(to verify server.pem), client.pem, client.key
|
||||
|
||||
If you have two ca.crt to generate server.crt and client.crt respectively, client1.crt is generate by ca1.crt and client1.key, server2.crt is generate by ca2.crt and server2.key:
|
||||
If you have two ca.pem to generate server.pem and client.pem respectively, client1.pem is generate by ca1.pem and client1.key, server2.pem is generate by ca2.pem and server2.key:
|
||||
|
||||
Client side needs ca2.crt, client1.crt, client1.key.
|
||||
Client side needs ca2.pem, client1.pem, client1.key.
|
||||
|
||||
Server side needs ca1.crt, server2.crt, server2.key.
|
||||
Server side needs ca1.pem, server2.pem, server2.key.
|
||||
|
||||
Rename ca2.crt client1.crt client1.key to ca.crt client.crt client.key and run ./genheader.sh.
|
||||
Rename ca2.pem client1.pem client1.key to ca.pem client.pem client.key.
|
||||
|
||||
Use ca1.crt in openssl s_server -CAfile option.
|
||||
Use ca1.pem in openssl s_server -CAfile option.
|
||||
|
||||
2. Run ./genheader.sh.
|
||||
2. Run `openssl s_server -CAfile ca.pem -cert server.pem -key server.key -verify 1 -tls1_2 -accept 443` in ./main directory to start server on your PC and wait for ESP8266 client to connect it.
|
||||
|
||||
3. Modify this two lines in file openssl_demo.c to your computer server ip and port.
|
||||
|
||||
```#define OPENSSL_DEMO_TARGET_NAME "192.168.3.196"```
|
||||
|
||||
```#define OPENSSL_DEMO_TARGET_TCP_PORT 443```
|
||||
|
||||
|
||||
4. Modify thease two lines in file user_config.h to your local Wi-Fi SSID and Password.
|
||||
|
||||
```#define SSID "HUAWEI001"```
|
||||
|
||||
```#define PASSWORD ""```
|
||||
|
||||
5. Make sure that the computer and ESP8266 are in the same local area network.
|
||||
|
||||
6. Run ./gen_misc.sh.
|
||||
|
||||
7. Run openssl s_server -CAfile ca.crt -cert server.crt -key server.key -verify 1 -tls1_1 -accept 443.
|
||||
|
||||
8. Download bin file to ESP8266.
|
||||
3. Compile and download
|
||||
- run `make menuconfig`
|
||||
- Modify SSID and PASSWORD under menu "Example Configuration".
|
||||
Make sure that the computer and ESP8266 are in the same local area network.
|
||||
- Modify TARGET_NAME and TARGET_PORT under menu "Example Configuration".
|
||||
- run `make flash monitor`
|
||||
|
||||
**ATTENTION**
|
||||
|
||||
@ -45,4 +31,4 @@
|
||||
|
||||
**2. Make sure the private key length larger than 2048.**
|
||||
|
||||
**3. Make sure the fragment size range is between 2048 and 8192.**
|
||||
**3. Make sure the fragment size range is between 2048 and 16384.**
|
Reference in New Issue
Block a user