Skip to content

Commit 17364ed

Browse files
committed
Last changes in docs and minor refactor/fixes in typing in Server method
1 parent 1bb84f9 commit 17364ed

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ HTTP Server for CircuitPython.
3232
- Supports URL parameters and wildcard URLs.
3333
- Supports HTTP Basic and Bearer Authentication on both server and route per level.
3434
- Supports Websockets and Server-Sent Events.
35-
- Limited support for HTTPS (only on selected microcontrollers e.g. ESP32-S3).
35+
- Limited support for HTTPS (only on selected microcontrollers with enough memory e.g. ESP32-S3).
3636

3737

3838
Dependencies

adafruit_httpserver/server.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,14 @@ class Server: # pylint: disable=too-many-instance-attributes
6060
"""Root directory to serve files from. ``None`` if serving files is disabled."""
6161

6262
@staticmethod
63-
def _validate_https_cert_provided(certfile: str, keyfile: str) -> None:
64-
if not certfile or not keyfile:
63+
def _validate_https_cert_provided(
64+
certfile: Union[str, None], keyfile: Union[str, None]
65+
) -> None:
66+
if certfile is None or keyfile is None:
6567
raise ValueError("Both certfile and keyfile must be specified for HTTPS")
6668

6769
@staticmethod
68-
def __create_circuitpython_ssl_context(certfile: str, keyfile: str) -> SSLContext:
70+
def _create_circuitpython_ssl_context(certfile: str, keyfile: str) -> SSLContext:
6971
ssl_context = create_default_context()
7072

7173
ssl_context.load_verify_locations(cadata="")
@@ -74,7 +76,7 @@ def __create_circuitpython_ssl_context(certfile: str, keyfile: str) -> SSLContex
7476
return ssl_context
7577

7678
@staticmethod
77-
def __create_cpython_ssl_context(certfile: str, keyfile: str) -> SSLContext:
79+
def _create_cpython_ssl_context(certfile: str, keyfile: str) -> SSLContext:
7880
ssl_context = create_default_context(purpose=Purpose.CLIENT_AUTH)
7981

8082
ssl_context.load_cert_chain(certfile, keyfile)
@@ -87,9 +89,9 @@ def __create_cpython_ssl_context(certfile: str, keyfile: str) -> SSLContext:
8789
@classmethod
8890
def _create_ssl_context(cls, certfile: str, keyfile: str) -> SSLContext:
8991
return (
90-
cls.__create_circuitpython_ssl_context(certfile, keyfile)
92+
cls._create_circuitpython_ssl_context(certfile, keyfile)
9193
if implementation.name == "circuitpython"
92-
else cls.__create_cpython_ssl_context(certfile, keyfile)
94+
else cls._create_cpython_ssl_context(certfile, keyfile)
9395
)
9496

9597
def __init__(

docs/examples.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,14 @@ video to multiple clients while simultaneously handling other requests.
372372
:emphasize-lines: 31-77,92
373373
:linenos:
374374

375-
SSL/TLS (HTTPS)
376-
---------------
375+
HTTPS
376+
-----
377377

378378
.. warning::
379-
For now HTTPS on CircuitPython is **only supported on ESP32-S3 boards**.
379+
HTTPS on CircuitPython **works only on boards with enough memory e.g. ESP32-S3**.
380380

381381
When you want to expose your server to the internet or an untrusted network, it is recommended to use HTTPS.
382-
Together with authentication, it provides a secure way to communicate with the server, without the risk of eavesdropping.
382+
Together with authentication, it provides a relatively secure way to communicate with the server.
383383

384384
.. note::
385385
Using HTTPS slows down the server, because of additional work with encryption and decryption.

0 commit comments

Comments
 (0)