From 86e677887fdc95b3b18f0a3106b07746a41f46e2 Mon Sep 17 00:00:00 2001 From: Oleg Ovcharuk Date: Tue, 27 Oct 2026 12:40:39 +0300 Subject: [PATCH 1/3] Remove distrusted roots from the bundled CA certificates --- CHANGELOG.md | 2 ++ docs/driver.rst | 10 ++++++-- ydb/_utilities_test.py | 28 +++++++++++++++++++++ ydb/default_pem.py | 56 ------------------------------------------ 4 files changed, 38 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44a1c411f..5815248ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +* Remove `AAA Certificate Services` and `emSign ECC Root CA - G3` from the bundled TLS trust store to reject certificate chains affected by the eMudhra CA compromise + ## 3.33.2 ## * Fix sync `QuerySessionPool` and `QuerySession.create()` hanging for 600 seconds and then failing with a non-retriable `TimeoutError` when a new session's attach stream fails before its first message (e.g. during a node restart); the attach error is now raised immediately, so retriable errors such as `Unavailable` are retried diff --git a/docs/driver.rst b/docs/driver.rst index d58762400..064df79a0 100644 --- a/docs/driver.rst +++ b/docs/driver.rst @@ -281,8 +281,14 @@ provider based on which environment variable is set: TLS / Secure Connections ------------------------- -For TLS endpoints (``grpcs://``), the SDK uses the system CA bundle by default. -To supply a custom CA certificate: +For TLS endpoints (``grpcs://``), the SDK uses its bundled CA certificates by +default. The bundle excludes ``AAA Certificate Services`` and +``emSign ECC Root CA - G3`` to reject certificate chains affected by the +`eMudhra CA compromise `_. +Both synchronous and asynchronous drivers use this bundle. + +To supply a custom CA certificate, pass ``root_certificates``. This replaces the +bundled certificates: .. code-block:: python diff --git a/ydb/_utilities_test.py b/ydb/_utilities_test.py index a154afd46..394fe5701 100644 --- a/ydb/_utilities_test.py +++ b/ydb/_utilities_test.py @@ -1,4 +1,6 @@ +import hashlib from pathlib import Path, PurePosixPath +import ssl import subprocess import sys import tarfile @@ -7,6 +9,7 @@ import pytest import ydb +from ydb import default_pem from ydb._utilities import check_module_exists from ydb._utilities import get_first_message_with_timeout @@ -14,6 +17,31 @@ from .ydb_version import VERSION +@pytest.mark.parametrize( + "fingerprint", + [ + pytest.param( + "d7a7a0fb5d7e2731d771e9484ebcdef71d5f0c3e0a2948782bc83ee0ea699ef4", + id="aaa-certificate-services", + ), + pytest.param( + "86a1ecba089c4a8d3bbe2734c612ba341d813e043cf9e8a862cd5c57a36bbe6b", + id="emsign-ecc-root-ca-g3", + ), + ], +) +def test_default_ca_bundle_excludes_distrusted_roots(fingerprint): + certificates = "\n".join( + line for line in default_pem.load_default_pem().decode("utf-8").splitlines() if not line.startswith("#") + ) + context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) + context.load_verify_locations(cadata=certificates) + fingerprints = {hashlib.sha256(cert).hexdigest() for cert in context.get_ca_certs(binary_form=True)} + + assert fingerprints + assert fingerprint not in fingerprints + + @pytest.mark.parametrize( "path,result", [("sys", True), ("ydb", True), ("ydb.some.module.unexisted.test", False)], diff --git a/ydb/default_pem.py b/ydb/default_pem.py index b8272efd2..42ffd4e19 100644 --- a/ydb/default_pem.py +++ b/ydb/default_pem.py @@ -326,39 +326,6 @@ QMAJKOSLakhT2+zNVVXxxvjpoixMptEmX36vWkzaH6byHCx+rgIW0lbQL1dTR+iS -----END CERTIFICATE----- -# Issuer: CN=AAA Certificate Services O=Comodo CA Limited -# Subject: CN=AAA Certificate Services O=Comodo CA Limited -# Label: "Comodo AAA Services root" -# Serial: 1 -# MD5 Fingerprint: 49:79:04:b0:eb:87:19:ac:47:b0:bc:11:51:9b:74:d0 -# SHA1 Fingerprint: d1:eb:23:a4:6d:17:d6:8f:d9:25:64:c2:f1:f1:60:17:64:d8:e3:49 -# SHA256 Fingerprint: d7:a7:a0:fb:5d:7e:27:31:d7:71:e9:48:4e:bc:de:f7:1d:5f:0c:3e:0a:29:48:78:2b:c8:3e:e0:ea:69:9e:f4 ------BEGIN CERTIFICATE----- -MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswC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F -AAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm7l3sAg9g1o1Q -GE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz -Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2 -G9w84FoVxp7Z8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsi -l2D4kF501KKaU73yqWjgom7C12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3 -smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg== ------END CERTIFICATE----- - # Issuer: CN=QuoVadis Root Certification Authority O=QuoVadis Limited OU=Root Certification Authority # Subject: CN=QuoVadis Root Certification Authority O=QuoVadis Limited OU=Root Certification Authority # Label: "QuoVadis Root CA" @@ -4501,29 +4468,6 @@ iN66zB+Afko= -----END CERTIFICATE----- -# Issuer: CN=emSign ECC Root CA - G3 O=eMudhra Technologies Limited OU=emSign PKI -# Subject: CN=emSign ECC Root CA - G3 O=eMudhra Technologies Limited OU=emSign PKI -# Label: "emSign ECC Root CA - G3" -# Serial: 287880440101571086945156 -# MD5 Fingerprint: ce:0b:72:d1:9f:88:8e:d0:50:03:e8:e3:b8:8b:67:40 -# SHA1 Fingerprint: 30:43:fa:4f:f2:57:dc:a0:c3:80:ee:2e:58:ea:78:b2:3f:e6:bb:c1 -# SHA256 Fingerprint: 86:a1:ec:ba:08:9c:4a:8d:3b:be:27:34:c6:12:ba:34:1d:81:3e:04:3c:f9:e8:a8:62:cd:5c:57:a3:6b:be:6b ------BEGIN CERTIFICATE----- -MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQG -EwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNo -bm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g -RzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4MTgzMDAwWjBrMQswCQYDVQQGEwJJ -TjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9s -b2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMw -djAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0 -WXTsuwYc58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xyS -fvalY8L1X44uT6EYGQIrMgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuB -zhccLikenEhjQjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggq -hkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+DCBeQyh+KTOgNG3qxrdWB -CUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7jHvrZQnD -+JbNR6iC8hZVdyR+EhCVBCyj ------END CERTIFICATE----- - # Issuer: CN=emSign Root CA - C1 O=eMudhra Inc OU=emSign PKI # Subject: CN=emSign Root CA - C1 O=eMudhra Inc OU=emSign PKI # Label: "emSign Root CA - C1" From 68611c02d8e888f21faa1a48aa8778dbc9f71278 Mon Sep 17 00:00:00 2001 From: Oleg Ovcharuk Date: Tue, 27 Oct 2026 15:47:05 +0300 Subject: [PATCH 2/3] Keep TLS documentation focused on connection setup --- docs/driver.rst | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/docs/driver.rst b/docs/driver.rst index 064df79a0..9c1e01b0b 100644 --- a/docs/driver.rst +++ b/docs/driver.rst @@ -281,14 +281,8 @@ provider based on which environment variable is set: TLS / Secure Connections ------------------------- -For TLS endpoints (``grpcs://``), the SDK uses its bundled CA certificates by -default. The bundle excludes ``AAA Certificate Services`` and -``emSign ECC Root CA - G3`` to reject certificate chains affected by the -`eMudhra CA compromise `_. -Both synchronous and asynchronous drivers use this bundle. - -To supply a custom CA certificate, pass ``root_certificates``. This replaces the -bundled certificates: +For TLS endpoints (``grpcs://``), the SDK uses its bundled CA certificates by default. +To supply a custom CA certificate: .. code-block:: python From b35a4ad08008ca238a56a21ddb5cae8402b9327b Mon Sep 17 00:00:00 2001 From: Oleg Ovcharuk Date: Tue, 27 Oct 2026 15:49:42 +0300 Subject: [PATCH 3/3] Limit the CA bundle fix to certificates and changelog --- docs/driver.rst | 2 +- ydb/_utilities_test.py | 28 ---------------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/docs/driver.rst b/docs/driver.rst index 9c1e01b0b..d58762400 100644 --- a/docs/driver.rst +++ b/docs/driver.rst @@ -281,7 +281,7 @@ provider based on which environment variable is set: TLS / Secure Connections ------------------------- -For TLS endpoints (``grpcs://``), the SDK uses its bundled CA certificates by default. +For TLS endpoints (``grpcs://``), the SDK uses the system CA bundle by default. To supply a custom CA certificate: .. code-block:: python diff --git a/ydb/_utilities_test.py b/ydb/_utilities_test.py index 394fe5701..a154afd46 100644 --- a/ydb/_utilities_test.py +++ b/ydb/_utilities_test.py @@ -1,6 +1,4 @@ -import hashlib from pathlib import Path, PurePosixPath -import ssl import subprocess import sys import tarfile @@ -9,7 +7,6 @@ import pytest import ydb -from ydb import default_pem from ydb._utilities import check_module_exists from ydb._utilities import get_first_message_with_timeout @@ -17,31 +14,6 @@ from .ydb_version import VERSION -@pytest.mark.parametrize( - "fingerprint", - [ - pytest.param( - "d7a7a0fb5d7e2731d771e9484ebcdef71d5f0c3e0a2948782bc83ee0ea699ef4", - id="aaa-certificate-services", - ), - pytest.param( - "86a1ecba089c4a8d3bbe2734c612ba341d813e043cf9e8a862cd5c57a36bbe6b", - id="emsign-ecc-root-ca-g3", - ), - ], -) -def test_default_ca_bundle_excludes_distrusted_roots(fingerprint): - certificates = "\n".join( - line for line in default_pem.load_default_pem().decode("utf-8").splitlines() if not line.startswith("#") - ) - context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) - context.load_verify_locations(cadata=certificates) - fingerprints = {hashlib.sha256(cert).hexdigest() for cert in context.get_ca_certs(binary_form=True)} - - assert fingerprints - assert fingerprint not in fingerprints - - @pytest.mark.parametrize( "path,result", [("sys", True), ("ydb", True), ("ydb.some.module.unexisted.test", False)],