Skip to content

Commit b75596e

Browse files
committed
Replace deprecated ssl.PROTOCOL_TLSv1_2 in the TCP client
Use ssl.PROTOCOL_TLS_CLIENT and explicitly disable CA verification and hostname checking, preserving the existing exact-certificate-pinning behavior. Verified against a real secured server (secured subscription tests pass).
1 parent 54479b7 commit b75596e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

ravendb/util/tcp_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ def connect(
2020

2121
is_ssl_socket = server_certificate_base64 and client_certificate_pem_path
2222
if is_ssl_socket:
23-
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
23+
# PROTOCOL_TLS_CLIENT replaces the deprecated PROTOCOL_TLSv1_2. Its defaults turn on
24+
# CA verification and hostname checking, which this code intentionally does not use -
25+
# the server is validated below by exact-certificate pinning - so disable both to keep
26+
# the previous behavior. (check_hostname must be cleared before setting CERT_NONE.)
27+
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
28+
context.check_hostname = False
29+
context.verify_mode = ssl.CERT_NONE
2430
context.load_cert_chain(client_certificate_pem_path, password=certificate_private_key_password)
2531
s = context.wrap_socket(s)
2632

0 commit comments

Comments
 (0)