PyWebOSTV icon indicating copy to clipboard operation
PyWebOSTV copied to clipboard

AttributeError: module 'ssl' has no attribute 'wrap_socket'

Open MarkStoutjesdijk opened this issue 1 year ago • 6 comments

Hi,

Using secure connection, I am getting an error:

AttributeError: module 'ssl' has no attribute 'wrap_socket'

I suspect it is due to a change in Python -- see https://github.com/eventlet/eventlet/issues/795. It would be great if you could take a look at this!

MarkStoutjesdijk avatar May 03 '24 15:05 MarkStoutjesdijk

Thanks! I didn't know about this one. This is indeed because ssl library changes in latest Python.

I was looking at the connect(..) here -- unfortunately, it looks like it hasn't been written in a manner that allows for SSL context to overridden by child classes, without copying the entire function.

That being said, we can perhaps try having ssl.wrap_socket point to something else ( HACKY + UNTESTED):

# Before any library imports that depends on ssl..
ssl.wrap_socket = ssl.SSLContext().wrap_socket

.. can you please confirm if this works for you? If so, I'll try incorporating this in this library..

supersaiyanmode avatar May 06 '24 12:05 supersaiyanmode

Thanks! I didn't know about this one. This is indeed because ssl library changes in latest Python.

I was looking [at the connect(..) here](https://github.com/Lawouach/WebSocket-for-Python/blob/961c07ce16ce4eedc34ca1fdacd29442870feccc/ws4py/client/__init__.py#L214) -- unfortunately, it looks like it hasn't been written in a manner that allows for SSL context to overridden by child classes, without copying the entire function.

That being said, we can perhaps try having `ssl.wrap_socket` point to something else ( **HACKY + UNTESTED**):

```
# Before any library imports that depends on ssl..
ssl.wrap_socket = ssl.SSLContext().wrap_socket
```

.. can you please confirm if this works for you? If so, I'll try incorporating this in this library..

--
Reply to this email directly or view it on GitHub:
https://github.com/supersaiyanmode/PyWebOSTV/issues/108#issuecomment-2095947350
You are receiving this because you authored the thread.

Message ID: ***@***.***>

MarkStoutjesdijk avatar May 12 '24 20:05 MarkStoutjesdijk

Yes, his solution works, add the protocol to skip the deprecation warning.

ssl.wrap_socket = ssl.SSLContext(protocol=ssl.PROTOCOL_TLSv1_2).wrap_socket

umetzu avatar Sep 18 '24 14:09 umetzu

Whas this already implemented? I just installed 8.10 but I am getting this error.

Exception has occurred: AttributeError module 'ssl' has no attribute 'wrap_socket' File "src/test.py", line 64, in client.connect() AttributeError: module 'ssl' has no attribute 'wrap_socket'

apppie123 avatar Oct 01 '24 15:10 apppie123