circuitpython/ports/raspberrypi/common-hal/ssl
Jeff Epler de9233f84a
raspberrypi: SSLSocket: raise OSError when appropriate
Rather than returning the negative error value.

This is intended to close #7606, though I did not test with mqtt.
Instead, I created a simple standalone test program:
```python
import wifi, socketpool, ssl, time
#wifi.radio.connect(<omitted>)
import socketpool
socket = socketpool.SocketPool(wifi.radio)
ctx = ssl.create_default_context()

b = bytearray(8)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sss = ctx.wrap_socket(s, server_hostname='example.com')
sss.connect(('example.com', 443))
sss.setblocking(False)
r = sss.recv_into(b)
print(r, b)  # prints 4294967285 which is -11 as unsigned
sss.close()
```

Before the change, r was the out of range value 4294967285. After the
change, the recv_into call raises OSError instead.

This is comparable to the behavior on standard Python, though an
SSLWantReadError is raised instead.

The original (mis)behavior seems to match what was uncovered deep inside
minimqtt by adding logging:
```
370.578: DEBUG - PKT: _sock_exact_recv: recv_len = 4294967285
```
2023-02-22 10:07:48 -06:00
..
SSLContext.c Pico W: Correctly treat empty cadata= as disabling host checking 2022-10-12 11:38:29 -05:00
SSLContext.h Add support for SSL client certificate (load_cert_chain) 2022-10-10 15:10:53 -05:00
SSLSocket.c raspberrypi: SSLSocket: raise OSError when appropriate 2023-02-22 10:07:48 -06:00
SSLSocket.h pico w: add ssl module 2022-10-05 13:12:43 -04:00
__init__.c More ssl work 2022-10-05 14:56:26 -05:00
__init__.h More ssl work 2022-10-05 14:56:26 -05:00