Commit Graph

28 Commits (master)

Author SHA1 Message Date
Kareem a69521afa4 Update license from GPLv2 to GPLv3. 2026-07-20 10:37:26 -07:00
Juliusz Sosinowicz 406cceb7ba Keep end-to-end example test compatible with Python 2.7
subprocess.run() is Python 3.5+. Use Popen with communicate() and a
threading.Timer watchdog in place of the communicate() timeout, which
is 3.3+.
2026-07-13 17:53:14 +00: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 d55a68d4ab Keep test_write_bytes.py source 7-bit ASCII
Use the \u00e9 escape instead of a literal e-acute. The test still
exercises multi-byte UTF-8 encoding.
2026-07-13 17:35:04 +00:00
Juliusz Sosinowicz 56e3297edd Skip hostname check for IP literal hosts in client example
Review follow-up for F-5621. wolfSSL_check_domain_name() only matches
DNS names: on this path CheckForAltNames() is called with isIP=0, so
iPAddress SANs are always skipped (verified on v5.8.4-stable and
master). The default invocation (host 127.0.0.1) therefore failed the
handshake with DOMAIN_NAME_MISMATCH (-322) once hostname verification
was enabled by default.

Skip the hostname check for IP literal hosts and say so, keeping
CERT_REQUIRED verification. This also stops offering an IP literal in
SNI, which RFC 6066 forbids. Connecting by DNS name still enables the
hostname check.

Add unit tests for the IP literal paths and an end-to-end test that
runs server.py and client.py with default arguments.
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 9c26572a41 Enable hostname verification in client example (F-5621)
The client example set CERT_REQUIRED and loaded CA roots but never set
check_hostname or passed server_hostname to wrap_socket, so wolfSSL
validated the chain to a trusted CA without binding the certificate to
the requested host. A peer presenting any CA-trusted certificate for a
different hostname would be accepted by anyone reusing this as a secure
client template. Make verification configure hostname checking by
default (via a new configure_verification helper) and add a -n flag to
opt out explicitly for IP literals or test certificates.
2026-06-24 12:26:37 +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
Juliusz Sosinowicz c29eb6760b Fix DTLS server example consuming the ClientHello before handshake (F-3481)
The DTLS branch called bind_socket.recvfrom(1) before creating the
context. On UDP that removes the entire first datagram (the client's
ClientHello) from the queue and discards everything past the first
byte, so wolfSSL_accept() had nothing to consume and the handshake
only recovered after the client's retransmit timer. The captured
from_addr was also reused for every iteration of the -i loop.

Replace it with a peek_peer_address() helper that uses MSG_PEEK to read
the source address without consuming the datagram, and move the peek
into the accept loop so the address is refreshed per connection.
2026-06-23 11:22:06 +00:00
Jeremiah Mackey 7a1c3b0885 Guard shutdowns and clean up code 2026-04-14 17:10:36 +00:00
Jeremiah Mackey ffd86dea5e Add tests for recent fixes 2026-04-02 15:40:04 +00:00
Kareem f4c6d17d7d Add testing to confirm that the server fails as expected if CERT_REQUIRED is set and the client doesn't send a cert. 2025-12-16 14:51:28 -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
Andrew Hutchings aea5844a10 Add support for disable-oldtls
If wolfSSL is build with `--disable-oldtls` then we need to support
this. Otherwise link errors will occur.
2022-07-22 13:20:13 +01:00
Andrew Hutchings 9d22a85445 Fix TLSv1.3 support
There were some missing pieces to the TLSv1.3 support, this adds them in
along with tests.
2022-07-15 11:07:43 +01: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
Chris Conlon 032f2e0167 update copyright to 2020 2020-01-03 16:24:35 -08:00
Chris Conlon e32799a5ed update copyright dates to 2019 2018-12-31 08:31:48 -08:00
Moisés Guimarães ef06c446f5 runs openssl tests only in python >= 3.6 2018-01-27 21:36:14 +01:00
Moisés Guimarães 85ac434af3 adds support to tls 1.3 2018-01-27 20:51:32 +01:00
Moisés Guimarães a0fed9d8d2 fixes pylint warnings 2018-01-09 12:43:56 -03:00
Moisés Guimarães 52ee72a6e4 fixes flake8 warnings 2018-01-09 12:14:44 -03:00
Moisés Guimarães 7afda6b253 build files 2017-12-19 14:46:42 -03:00