Skip to content

Commit d5871a2

Browse files
SNOW-1920533 match privatelink in hostname to setup correct privatelink OCSP Cache url even if user specifies account in UPPERCASE (#2169)
1 parent 112395d commit d5871a2

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

DESCRIPTION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
1212
- Removed the workaround for a Python 2.7 bug.
1313
- Added a <19.0.0 pin to pyarrow as a workaround to a bug affecting Azure Batch.
1414
- Optimized distribution package lookup to speed up import.
15+
- Fixed a bug where privatelink OCSP Cache url could not be determined if privatelink account name was specified in uppercase
1516

1617
- v3.13.2(January 29, 2025)
1718
- Changed not to use scoped temporary objects.

src/snowflake/connector/connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ def __set_error_attributes(self) -> None:
926926

927927
@staticmethod
928928
def setup_ocsp_privatelink(app, hostname) -> None:
929+
hostname = hostname.lower()
929930
SnowflakeConnection.OCSP_ENV_LOCK.acquire()
930931
ocsp_cache_server = f"http://ocsp.{hostname}/ocsp_response_cache.json"
931932
os.environ["SF_OCSP_RESPONSE_CACHE_SERVER_URL"] = ocsp_cache_server
@@ -957,7 +958,7 @@ def __open_connection(self):
957958
os.environ["SF_OCSP_RESPONSE_CACHE_SERVER_URL"],
958959
)
959960

960-
if ".privatelink.snowflakecomputing." in self.host:
961+
if ".privatelink.snowflakecomputing." in self.host.lower():
961962
SnowflakeConnection.setup_ocsp_privatelink(self.application, self.host)
962963
else:
963964
if "SF_OCSP_RESPONSE_CACHE_SERVER_URL" in os.environ:

test/integ/test_connection.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,19 @@ def test_privatelink_ocsp_url_creation():
672672
)
673673

674674

675+
@pytest.mark.skipolddriver
676+
def test_uppercase_privatelink_ocsp_url_creation():
677+
account = "TESTACCOUNT.US-EAST-1.PRIVATELINK"
678+
hostname = account + ".snowflakecomputing.com"
679+
680+
SnowflakeConnection.setup_ocsp_privatelink(CLIENT_NAME, hostname)
681+
ocsp_cache_server = os.getenv("SF_OCSP_RESPONSE_CACHE_SERVER_URL", None)
682+
assert (
683+
ocsp_cache_server
684+
== "http://ocsp.testaccount.us-east-1.privatelink.snowflakecomputing.com/ocsp_response_cache.json"
685+
)
686+
687+
675688
def test_privatelink_ocsp_url_multithreaded():
676689
bucket = queue.Queue()
677690

0 commit comments

Comments
 (0)