README.md
1# HTTP server with SSL support using OpenSSL
2
3This example creates a SSL server that returns a simple HTML page when you visit its root URL.
4
5See the `esp_https_server` component documentation for details.
6
7## How to use example
8Before project configuration and build, be sure to set the correct chip target using `idf.py set-target <chip_name>`.
9
10### Configure the project
11
12```
13idf.py menuconfig
14```
15Open the project configuration menu (`idf.py menuconfig`) to configure Wi-Fi or Ethernet. See "Establishing Wi-Fi or Ethernet Connection" section in [examples/protocols/README.md](../../README.md) for more details.
16
17### Build and Flash
18
19Build the project and flash it to the board, then run monitor tool to view serial output:
20
21```
22idf.py -p PORT flash monitor
23```
24
25(Replace PORT with the name of the serial port to use.)
26
27(To exit the serial monitor, type ``Ctrl-]``.)
28
29See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
30
31## Certificates
32
33You will need to approve a security exception in your browser. This is because of a self signed
34certificate; this will be always the case, unless you preload the CA root into your browser/system
35as trusted.
36
37You can generate a new certificate using the OpenSSL command line tool:
38
39```
40openssl req -newkey rsa:2048 -nodes -keyout prvtkey.pem -x509 -days 3650 -out cacert.pem -subj "/CN=ESP32 HTTPS server example"
41```
42
43Expiry time and metadata fields can be adjusted in the invocation.
44
45Please see the openssl man pages (man openssl-req) for more details.
46
47It is **strongly recommended** to not reuse the example certificate in your application;
48it is included only for demonstration.
49
50## Example Output
51
52```
53I (8596) example: Starting server
54I (8596) esp_https_server: Starting server
55I (8596) esp_https_server: Server listening on port 443
56I (8596) example: Registering URI handlers
57I (8606) esp_netif_handlers: example_connect: sta ip: 192.168.194.219, mask: 255.255.255.0, gw: 192.168.194.27
58I (8616) example_connect: Got IPv4 event: Interface "example_connect: sta" address: 192.168.194.219
59I (9596) example_connect: Got IPv6 event: Interface "example_connect: sta" address: fe80:0000:0000:0000:266f:28ff:fe80:2c74, type: ESP_IP6_ADDR_IS_LINK_LOCAL
60I (9596) example_connect: Connected to example_connect: sta
61W (9606) wifi:<ba-add>idx:0 (ifx:0, ee:6d:19:60:f6:0e), tid:0, ssn:2, winSize:64
62I (9616) example_connect: - IPv4 address: 192.168.194.219
63I (9616) example_connect: - IPv6 address: fe80:0000:0000:0000:266f:28ff:fe80:2c74, type: ESP_IP6_ADDR_IS_LINK_LOCAL
64W (14426) wifi:<ba-add>idx:1 (ifx:0, ee:6d:19:60:f6:0e), tid:4, ssn:0, winSize:64
65I (84896) esp_https_server: performing session handshake
66```
67