Skip to content

Commit 14d6bef

Browse files
committed
Added docs about SSL/TLS
1 parent 736471a commit 14d6bef

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/examples.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,35 @@ This might change in the future, but for now, it is recommended to use Websocket
352352
:emphasize-lines: 12,20,65-72,88,99
353353
:linenos:
354354

355+
SSL/TLS (HTTPS)
356+
---------------
357+
358+
.. warning::
359+
For now HTTPS on CircuitPython is **only supported on ESP32-S3 boards**.
360+
361+
When you want to expose your server to the internet or an untrusted network, it is recommended to use HTTPS.
362+
Together with authentication, it provides a secure way to communicate with the server, without the risk of eavesdropping.
363+
364+
.. note::
365+
Using HTTPS slows down the server, because of additional work with encryption and decryption.
366+
367+
Enabling HTTPS is straightforward and comes down to passing the path to the certificate and key files to the ``Server`` constructor
368+
and setting ``https=True``.
369+
370+
.. literalinclude:: ../examples/httpserver_https.py
371+
:caption: examples/httpserver_https.py
372+
:emphasize-lines: 15-17
373+
:linenos:
374+
375+
376+
To create your own certificate, you can use the following command:
377+
378+
.. code-block:: bash
379+
380+
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.pem -out cert.pem
381+
382+
You might have to change permissions of the files, so that the server can read them.
383+
355384
Multiple servers
356385
----------------
357386

0 commit comments

Comments
 (0)