Commit Graph

35 Commits (f112ced76f72ed65645b59ee13114d21039254fc)

Author SHA1 Message Date
Kareem a69521afa4 Update license from GPLv2 to GPLv3. 2026-07-20 10:37:26 -07:00
Juliusz Sosinowicz 0446e8c73f Harden WolfSSLX509 constructor type discrimination
Compare interned cffi type objects instead of rendered type name
strings and raise TypeError for anything that is not a WOLFSSL* or
WOLFSSL_X509*.
2026-07-13 17:35:04 +00:00
Juliusz Sosinowicz 93954c9430 Return None from getpeercert when peer has no certificate (F-5623)
get_peer_x509() checked only whether the session was NULL and then built
a WolfSSLX509, whose __init__ called wolfSSL_get_peer_certificate() and
raised SSLError on NULL. On a valid connection where the peer presented
no certificate (e.g. a server not requesting a client cert), this raised
instead of returning None as the stdlib ssl getpeercert() contract
requires. Fetch the certificate in get_peer_x509(), return None when it
is NULL, and have WolfSSLX509 wrap the already-obtained pointer.
2026-06-24 12:27:57 +00:00
Juliusz Sosinowicz 3dd1b902e1 Send bytes-like data verbatim in SSLSocket.write (F-5622)
write() converted data with t2b(), which str()-encodes anything that is
not already bytes. Valid bytes-like inputs such as bytearray and
memoryview were transmitted as their Python repr ("bytearray(b'...')",
"<memory at ...>") instead of their contents, corrupting the stream.
Convert via the buffer protocol (bytes(memoryview(data))) and raise
TypeError for objects that are not bytes-like, matching the stdlib ssl
module.
2026-06-24 12:27:28 +00:00
Juliusz Sosinowicz 99a4416771 Drive DTLS handshake only until complete in I/O methods (F-4136)
For DTLS, write()/read()/recv_into() called do_handshake() on every
call. do_handshake() runs wolfSSL_accept/connect, which on a
non-blocking socket can raise SSLWantReadError and abort an I/O long
after the handshake finished, and made DTLS write-side behaviour
inconsistent with TCP. Track completion with a _handshake_complete
flag set on a successful do_handshake(), and only drive the handshake
from I/O methods while that flag is False.
2026-06-23 11:33:22 +00:00
Juliusz Sosinowicz 65aaef9750 Map WANT_WRITE from SSLSocket.recv_into() to SSLWantWriteError (F-3907)
recv_into() shares read()'s error-mapping pattern and inherited the
same omission: wolfSSL_read returning WOLFSSL_ERROR_WANT_WRITE (during
a renegotiation needing a write) was reported as a generic SSLError
instead of SSLWantWriteError, breaking non-blocking callers that
distinguish readiness directions. Add the WANT_WRITE branch.
2026-06-23 11:25:08 +00:00
Juliusz Sosinowicz d0bb56e6f9 Map WANT_WRITE from SSLSocket.read() to SSLWantWriteError (F-3906)
wolfSSL_read can return WOLFSSL_ERROR_WANT_WRITE when the SSL layer
must flush a handshake record (e.g. renegotiation) before returning
data. read() only handled WANT_READ, raising a generic SSLError
otherwise, which stops non-blocking callers from select()-ing on
writability. Add a WANT_WRITE branch raising SSLWantWriteError.
2026-06-23 11:24:40 +00:00
Juliusz Sosinowicz 41561e7ba6 Map WANT_READ from SSLSocket.write() to SSLWantReadError (F-3905)
wolfSSL_write can return WOLFSSL_ERROR_WANT_READ (e.g. during a
renegotiation that must read a record before progressing; secure
renegotiation is enabled by default). write() only handled WANT_WRITE,
so WANT_READ fell through to a generic SSLError and non-blocking
callers tore the session down. Add a WANT_READ branch raising
SSLWantReadError, matching do_handshake().
2026-06-23 11:24:10 +00:00
Jeremiah Mackey 7a1c3b0885 Guard shutdowns and clean up code 2026-04-14 17:10:36 +00:00
Jeremiah Mackey 2c4ba3c8d7 Fix low-severity issues 2026-04-02 16:32:27 +00:00
Jeremiah Mackey e1ede238e4 Fix wolfSSL_Init return type and check 2026-04-02 16:00:08 +00:00
Jeremiah Mackey c81c839a24 Free peer address on set_peer failure 2026-04-02 15:59:15 +00:00
Jeremiah Mackey 760cb466a7 Shutdown and free SSL in unwrap 2026-04-02 15:58:52 +00:00
Jeremiah Mackey 89667f9f7a Add null checks to version/pending 2026-04-02 15:53:32 +00:00
Jeremiah Mackey 84bd6375a2 Copy DER buffer in get_der 2026-04-02 15:52:47 +00:00
Jeremiah Mackey a406dce6c3 Add DTLS handshake to recv_into 2026-04-02 15:47:36 +00:00
Jeremiah Mackey 63b1ee8d17 Enforce CERT_REQUIRED for check_hostname 2026-03-19 16:02:17 +00:00
Jeremiah Mackey e15bf07408 Null native_object after CTX_free 2026-03-19 15:52:11 +00:00
Jeremiah Mackey 5e77b6cbcb Check wolfSSL_write return value 2026-03-19 15:51:03 +00:00
Jeremiah Mackey 40b35a4e36 Free X509 in WolfSSLX509.__del__ 2026-03-19 15:46:53 +00:00
Jeremiah Mackey c5ed261a4e Return None from get_peer_x509 2026-03-19 15:46:06 +00:00
Jeremiah Mackey ad2f7c6046 Fix wrong alert description function 2026-03-19 15:45:34 +00:00
Jeremiah Mackey 9a73852678 Check wolfSSL_check_domain_name return 2026-03-19 15:41:42 +00:00
Jeremiah Mackey 08737fab72 Fix wrap_socket server_side mismatch 2026-03-19 15:40:31 +00:00
Chris Conlon 8b3adf3023 Fix silent NameError when CFFI bindings are missing, adds _FFIPlaceholder that raises ImportError with instructions 2026-03-02 15:54:48 -07:00
Kareem b4517dece7 Fix CERT_REQUIRED verify mode not setting SSL_VERIFY_FAIL_IF_NO_PEER_CERT and therefore failing to verify the client cert.
Thanks to Matan Radomski for the report.
2025-12-15 11:58:26 -07:00
Marco Oliverio 4064227489 SSLSocket: support version() method 2024-07-18 18:53:27 +00:00
ZackLabPC 2a19d75d79 segfault issue fix from urllib3 tests 2023-08-04 13:37:11 -06:00
Lealem Amedie 1f88948c51 Adding DTLS13 support 2022-08-29 23:00:52 -07:00
Lealem Amedie e26560bf55 Adding DTLS support 2022-08-29 23:00:52 -07:00
Lealem Amedie 8117569866 Adding CRL support 2022-08-29 23:00:52 -07:00
Andrew Hutchings d57b7e9dcd Refactor build to be more Python-like
This ports over some of the fixes made to wolfCrypt. Some of this will
be pre-requisites for Windows support.

Build recursion fixes:
* Don't import module being built in setup.py
* Don't build the C code until we are doing binary dist or install
* Tox tests bdist_wheel instead of source

Other fixes:
* Separate out version to separate file for modifying
* Update copyright dates
* Unification of _build_ffi and _build_wolfssl
2022-02-08 15:04:22 +00:00
David Garske f349d08302 Minor spelling fixes. 2022-02-07 11:17:40 -08:00
Andrew Hutchings f7072afbb3 Fix TLSv1_3 constant bug 2022-01-20 17:01:23 +00:00
Andrew Hutchings b34b40f7f4 Update wolfSSL to 5.1.1 and fix any issues
* Bumps to wolfSSL 5.1.1
* Fixup `make clean`
* Move `wolfssl` src to root
* Switch test from DigiCert to GlobalSign (`python.org` ditched DigiCert
  years ago)
* Make SSLContext call `wolfSSL_Init()` which fixes a few issues
* Make `setup.py` compile CFFI and wolfSSL C code
* Fully enable SSLv3 support
* Add TLSv1.3 support
* Fix bug in `wolfSSL_Free()` usage
* Update `tox.ini` to a currently supported platform
2022-01-20 12:13:57 +00:00