Skip to content

Run on platforms without ssl #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Neradoc
Copy link
Contributor

@Neradoc Neradoc commented Mar 23, 2025

Catch the errors when importing ssl, and raise an exception in Server init when https is set.
This will allow using httpserver on ESP32SPI with adafruit/Adafruit_CircuitPython_ESP32SPI#218
Fixes #102

@anecdata
Copy link
Member

anecdata commented Mar 23, 2025

The hashlib import prints the warning right away, as @michalpokusa points out in the issue:
https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer/blob/09e5431071d9e484726df87841a5b9bbe33b6d76/adafruit_httpserver/response.py#L20-29

Should these both be done the same way (whichever of the two), or is there a reason to do them differently?

@Neradoc
Copy link
Contributor Author

Neradoc commented Mar 23, 2025

The warning for hashlib can be overcome by installing the library in question. Installing ssl is not an option (other than creating a dummy ssl.py for example), so this would only be a forced print every time with no purpose.

In fact I would argue that the warning for hashlib should be removed but I chose not to do it in this PR. It doesn't bring anything useful when not using websockets, and it's redundant with the error that will happen when trying to. In general such prints should not happen unless there's a "debug" or "verbose" option set somewhere.

For SSL it would be also interesting in the future to support other implementations by injecting it as a dependency and import the necessary libraries only when desired, but that's way beyond the scope of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSL import error
2 participants