examples: Add esp-ssl example tests server/client

Closes IDF-1156
This commit is contained in:
suren.gabrielyan
2021-02-11 00:46:28 +04:00
committed by Suren Gabrielyan
parent 822cdd81ef
commit 823abfdfd5
24 changed files with 600 additions and 233 deletions

View File

@@ -1,22 +1,65 @@
# Openssl Example
# OpenSSL Server Example
The Example contains of OpenSSL server demo.
(See the README.md file in the upper level 'examples' directory for more information about examples.)
Open the project configuration menu (`idf.py menuconfig`):
This example connects to the ESP-OPENSSL server demo using ssl transport and and sends some messages.
* Configure Wi-Fi or Ethernet under "Example Connection Configuration" menu. See "Establishing Wi-Fi or Ethernet Connection" section in [examples/protocols/README.md](../README.md) for more details.
## How to use example
### Python scripts
Script example_test.py could be used as a client part to the ESP-OPENSSL server demo,
```
python example_test.py
```
Note that this script is used in automated tests, as well, so the IDF test framework packages need to be imported;
please add `$IDF_PATH/tools/ci/python_packages` to `PYTHONPATH`.
### Hardware Required
This example can be executed on any ESP32 board, the only required interface is WiFi and connection to internet.
### Configure the project
* Open the project configuration menu (`idf.py menuconfig`)
* Configure Wi-Fi or Ethernet under "Example Connection Configuration" menu. See "Establishing Wi-Fi or Ethernet Connection" section in [examples/protocols/README.md](../../README.md) for more details.
* When using Make build system, set `Default serial port` under `Serial flasher config`.
IF you want to test the OpenSSL server demo:
1. compile the code and load the firmware
2. input the context of "https://192.168.17.128" into your web browser, the IP of your module may not be 192.168.17.128, you should input your module's IP
3. You may see that it shows the website is not able to be trusted, but you should select that "go on to visit it"
4. You should wait for a moment until your see the "OpenSSL server demo!" in your web browser
Note:
The private key and certification at the example are not trusted by web browser, because they are not created by CA official, just by ourselves.
You can alse create your own private key and ceritification by "openssl at ubuntu or others".
We have the document of "ESP8266_SDKSSL_User_Manual_EN_v1.4.pdf" at "https://www.espressif.com/en/support/download/documents". By it you can gernerate the private key and certification with the fomate of ".pem"
See the README.md file in the upper level 'examples' directory for more information about examples.
### Build and Flash
Build the project and flash it to the board, then run monitor tool to view serial output:
```
idf.py -p PORT flash monitor
```
(To exit the serial monitor, type ``Ctrl-]``.)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
## Example Output
```
I (2609) example_connect: Got IPv6 event: Interface "example_connect: sta" address: fe80:0000:0000:0000:260a:c4ff:fee7:a660, type: ESP_IP6_ADDR_IS_LINK_LOCAL
I (3609) esp_netif_handlers: example_connect: sta ip: 192.168.1.191, mask: 255.255.255.0, gw: 192.168.1.1
I (3609) example_connect: Got IPv4 event: Interface "example_connect: sta" address: 192.168.1.191
I (3619) example_connect: Connected to example_connect: sta
I (3619) example_connect: - IPv4 address: 192.168.1.191
I (3629) example_connect: - IPv6 address: fe80:0000:0000:0000:260a:c4ff:fee7:a660, type: ESP_IP6_ADDR_IS_LINK_LOCAL
I (3639) OPENSSL_EXAMPLE: SSL server context create ......
I (3649) OPENSSL_EXAMPLE: OK
I (3649) OPENSSL_EXAMPLE: SSL server context set own certification......
I (3659) OPENSSL_EXAMPLE: OK
I (3659) OPENSSL_EXAMPLE: SSL server context set private key......
I (3669) OPENSSL_EXAMPLE: OK
I (3669) OPENSSL_EXAMPLE: SSL server create socket ......
I (3679) OPENSSL_EXAMPLE: OK
I (3679) OPENSSL_EXAMPLE: SSL server socket bind ......
I (3689) OPENSSL_EXAMPLE: OK
I (3689) OPENSSL_EXAMPLE: SSL server socket listen on 443 port
I (3699) OPENSSL_EXAMPLE: OK
I (3699) OPENSSL_EXAMPLE: SSL server create ......
I (3709) OPENSSL_EXAMPLE: OK
I (3709) OPENSSL_EXAMPLE: SSL server socket accept client ......
```