Skip to content

Commit b4517de

Browse files
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.
1 parent 3e4ec84 commit b4517de

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

tests/test_context.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def test_verify_mode(ssl_provider, ssl_context):
3939

4040
assert ssl_context.verify_mode == ssl_provider.CERT_NONE
4141

42+
ssl_context.verify_mode = ssl_provider.CERT_OPTIONAL
43+
assert ssl_context.verify_mode == ssl_provider.CERT_OPTIONAL
44+
4245
ssl_context.verify_mode = ssl_provider.CERT_REQUIRED
4346
assert ssl_context.verify_mode == ssl_provider.CERT_REQUIRED
4447

wolfssl/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,15 @@
5555
PROTOCOL_DTLSv1_3, WolfSSLMethod as _WolfSSLMethod
5656
)
5757

58-
CERT_NONE = 0
59-
CERT_REQUIRED = 1
58+
_SSL_VERIFY_NONE = 0
59+
_SSL_VERIFY_PEER = 1
60+
_SSL_VERIFY_FAIL_IF_NO_PEER_CERT = 2
6061

61-
_VERIFY_MODE_LIST = [CERT_NONE, CERT_REQUIRED]
62+
CERT_NONE = _SSL_VERIFY_NONE
63+
CERT_OPTIONAL = _SSL_VERIFY_PEER
64+
CERT_REQUIRED = (_SSL_VERIFY_PEER | _SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
65+
66+
_VERIFY_MODE_LIST = [CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED]
6267

6368
_SSL_SUCCESS = 1
6469
_SSL_FILETYPE_PEM = 1

0 commit comments

Comments
 (0)