Skip to content

Commit 9e3efa8

Browse files
committed
fix ssl deactivation from catalog properties #2985
1 parent b98de51 commit 9e3efa8

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

pyiceberg/catalog/rest/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def _create_session(self) -> Session:
358358

359359
# Sets the client side and server side SSL cert verification, if provided as properties.
360360
if ssl_config := self.properties.get(SSL):
361-
if ssl_ca_bundle := ssl_config.get(CA_BUNDLE):
361+
if (ssl_ca_bundle := ssl_config.get(CA_BUNDLE)) is not None:
362362
session.verify = ssl_ca_bundle
363363
if ssl_client := ssl_config.get(CLIENT):
364364
if all(k in ssl_client for k in (CERT, KEY)):

tests/catalog/test_rest.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
NoSuchViewError,
4848
OAuthError,
4949
ServerError,
50-
TableAlreadyExistsError,
50+
TableAlreadyExistsError, ValidationError,
5151
)
5252
from pyiceberg.io import load_file_io
5353
from pyiceberg.partitioning import PartitionField, PartitionSpec
@@ -1641,6 +1641,29 @@ def test_update_namespace_properties_invalid_namespace(rest_mock: Mocker) -> Non
16411641
assert "Empty namespace identifier" in str(e.value)
16421642

16431643

1644+
def test_with_disabled_ssl_ca_bundle(rest_mock: Mocker) -> None:
1645+
from pydantic import ValidationError
1646+
def ssl_check_callback(req, _):
1647+
if req.verify:
1648+
raise AssertionError("SSL verification is still enabled")
1649+
# Given
1650+
rest_mock.get(
1651+
f"{TEST_URI}v1/config",
1652+
json=ssl_check_callback,
1653+
status_code=200,
1654+
)
1655+
# Given
1656+
catalog_properties = {
1657+
"uri": TEST_URI,
1658+
"token": TEST_TOKEN,
1659+
"ssl": {
1660+
"cabundle": False,
1661+
}
1662+
}
1663+
with pytest.raises(ValidationError) as _:
1664+
RestCatalog("rest", **catalog_properties)
1665+
1666+
16441667
def test_request_session_with_ssl_ca_bundle(monkeypatch: pytest.MonkeyPatch) -> None:
16451668
# Given
16461669
catalog_properties = {

0 commit comments

Comments
 (0)