Skip to content
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

Having another look at SSL in Micropython #102

Open
DracoTomes opened this issue Feb 18, 2024 · 3 comments
Open

Having another look at SSL in Micropython #102

DracoTomes opened this issue Feb 18, 2024 · 3 comments

Comments

@DracoTomes
Copy link

I just tried enabling SSL on my MicroPython project and had a pretty bad time.
I only afterwards stumbled on this Issue, basically stating HTTPS is not supported on MicroPython.

Given that MicroPython has recently started redoing a lot of the ssl Implementation how willing are you to have a look at what it would take to implement this into the XAsyncSockets library?

@jczic
Copy link
Owner

jczic commented Feb 18, 2024

Hello @DracoTomes,
That's a good question indeed ☺️
I don't have much time at the moment, but it would be interesting to review how SSL (TLS) works in MicroPython.
I know that SSLContext was required for this to work.
(The server works very well in SSL on a Unix market (it does asynchronous and concurrent concurrency)).

I use it in production!

Is this really urgent for you? 🚀

@DracoTomes
Copy link
Author

No this is not urgent.

Originally I also failed here

https://github.com/jczic/MicroWebSrv2/blob/2f1e982cad28be776d124bfeaae34e01f82fe177/MicroWebSrv2/microWebSrv2.py#L312C9-L314C63

I then tried replacing the create_default_context with something like this

ctx = new ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
try:
    load_verify_locations(caFile)
except :
    raise ValueError('"caFile" must indicate a valid PEM file.')

but then had the issue that the new SSLContext does not implement .fileno() and this failed:

https://github.com/jczic/MicroWebSrv2/blob/2f1e982cad28be776d124bfeaae34e01f82fe177/MicroWebSrv2/libs/XAsyncSockets.py#L61C5-L63C39

and I gave up.

I guess the first interesting thing is how much work you roughly estimate this would take, if feasible at all?

@jczic
Copy link
Owner

jczic commented Feb 18, 2024

I don't know how long it would take with MicroPython because it would be important for me to get the ESP32 boards out and have a bit of time (I'm setting up a business at the moment and I've got a lot of work to do).
However, I see that SSLContext now seems to exist in MicroPython and fileno() exists in socket objects normally.

https://docs.micropython.org/en/latest/library/ssl.html#class-sslcontext

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

No branches or pull requests

2 participants