jczic / MicroWebSrv2

The last Micro Web Server for IoTs (MicroPython) or large servers (CPython), that supports WebSockets, routes, template engine and with really optimized architecture (mem allocations, async I/Os). Ready for ESP32, STM32 on Pyboard, Pycom's chipsets (WiPy, LoPy, ...). Robust, efficient and documented!
https://github.com/jczic/MicroWebSrv2
MIT License
662 stars 97 forks source link

SSL library #18

Closed sniperini closed 4 years ago

sniperini commented 4 years ago

Hello,

I am trying to enable SSL on my ESP32 Micropython latest compiled FW, but unfortunately your following requirements for SSL python library are hard to comply:

The ssl library must be implements SSLContext on Python 
version to support secured web server

The ussl (https://github.com/micropython/micropython-lib/blob/master/ssl/ssl.py) library that Micropython uses doesn't have create_default_context method and SSLContext class and , only wrap_socket method from it.

Same goes for Pycom: https://docs.pycom.io/firmwareapi/micropython/ussl/

The only one I found that has everything, is CPython full implementation of SSL. https://github.com/python/cpython/blob/master/Lib/ssl.py

But then again, micropython doesn't have all those dependencies to even load it, starting from importing Enum module... Basically it needs to be rewritten how it was done with USSL.

Could you please clarify which library are you using that has that SSLContext class and create_default_context method?

Is it possible to adopt MicroWebSrv2 to comply with Micropython implementation of SSL somehow?

Thanks!

jczic commented 4 years ago

Hello @sniperini, and thank you for your interest 👍

About SSL, I know very well that SSLContext doesn't exists on MicroPython but the standard wrap_socket method and other implementations with a differed handshake do not works correctly in asynchronous mode and moreover, supported SSL versions are old. For the moment, it is therefore intentionally that there is no support.

MinaDarsh commented 4 years ago

I was reading into this, still learning, and it throws a wrench in the plan I had. I want to run a little server on a Pycom Wipy 3.0, with secure log in.

Is there a way this could still be realized?

jczic commented 4 years ago

Hi, I'm sorry but on MicroPython for Pycom, SSL client support is ok but the server mode is restricted and causes problems with web browsers to properly negotiate the TLS layer... I was also disappointed. :(