Closed ekondayan closed 11 months ago
This is still not entirely fixed, I ran into issues on my ESP32 because SSLSocket is still used a few lines below it. https://github.com/jczic/MicroWebSrv2/blob/7646c7535a4d1236ac98210a04cbb6ffba1c31bf/MicroWebSrv2/libs/XAsyncSockets.py#L835-L838 Replacing that will SSLContext as well (as actually checked in the function) works for me.
Ok @DracoTomes, that means that in MicroPython you have "SSLContext" as a socket attribute, otherwise the IF wouldn't go any further. However, self._socket is in no way part of the SSLContext class. I will therefore also test "SSLSocket" as an attribute.
I know that the latest version of MicroPython implements SSL (TLS) with context and asynchronously, because this didn't exist before. But I haven't checked yet.
So I guess you don't use SSL in MicroPython at all?
https://github.com/jczic/MicroWebSrv2/commit/b6f0799d07b36c9ec1b7273908642c77680f2c1f
The line "hasattr(ssl, 'SSLContext')" indicates that the system manages SSL "contexts". I know this worked on MicroPython but there must have been a change in some versions.
I'm running the newest 1.22.1 so it's probably something to do with the changes in newer version. I have not used SSL yet (except for outgoing requests but I don't think that should matter).
@DracoTomes : But it should work now, shouldn't it?
Oh yeah my bad. After implementing that change everything worked.
👍🏻
The bug is in function IsSSL where the _socket object is tested to be an instance of SSLSocket. The correct is to test if the object is of class SSLContext.
https://github.com/jczic/MicroWebSrv2/issues/95
The SSLSocket attribute is not available in micropython for port esp32 and when initiating a simple GET crashes the server.
Unhandled exception in thread started by
Traceback (most recent call last):
File "MicroWebSrv2/libs/XAsyncSockets.py", line 131, in _processWaitEvents
File "MicroWebSrv2/libs/XAsyncSockets.py", line 587, in OnReadyForReading
File "MicroWebSrv2/libs/XAsyncSockets.py", line 830, in IsSSL
AttributeError: 'module' object has no attribute 'SSLSocket'