Skip to content

Commit 4067b42

Browse files
Apply #2165 changes to async code
1 parent ab4de62 commit 4067b42

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

src/snowflake/connector/aio/_connection.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pathlib
1212
import sys
1313
import uuid
14+
import warnings
1415
from contextlib import suppress
1516
from io import StringIO
1617
from logging import getLogger
@@ -496,6 +497,26 @@ def _init_connection_parameters(
496497
elif "streamlit" in sys.modules:
497498
connection_init_kwargs["application"] = "streamlit"
498499

500+
if "insecure_mode" in connection_init_kwargs:
501+
warn_message = "The 'insecure_mode' connection property is deprecated. Please use 'disable_ocsp_checks' instead"
502+
warnings.warn(
503+
warn_message,
504+
DeprecationWarning,
505+
stacklevel=2,
506+
)
507+
508+
if (
509+
"disable_ocsp_checks" in connection_init_kwargs
510+
and connection_init_kwargs["disable_ocsp_checks"]
511+
!= connection_init_kwargs["insecure_mode"]
512+
):
513+
logger.warning(
514+
"The values for 'disable_ocsp_checks' and 'insecure_mode' differ. "
515+
"Using the value of 'disable_ocsp_checks."
516+
)
517+
else:
518+
self._disable_ocsp_checks = connection_init_kwargs["insecure_mode"]
519+
499520
self.converter = None
500521
self.query_context_cache: QueryContextCache | None = None
501522
self.query_context_cache_size = 5

src/snowflake/connector/aio/_ocsp_asn1crypto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def extract_certificate_chain(self, connection: ResponseHandler):
2727
"Please open an issue on the Snowflake Python Connector GitHub repository "
2828
"and provide your execution environment"
2929
" details: https://github.com/snowflakedb/snowflake-connector-python/issues/new/choose."
30-
"As a workaround, you can create the connection with `insecure_mode=True` to skip OCSP Validation."
30+
"As a workaround, you can create the connection with `disable_ocsp_checks=True` to skip OCSP Validation."
3131
)
3232

3333
cert_map = OrderedDict()

src/snowflake/connector/aio/_ocsp_snowflake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ async def validate(
206206

207207
telemetry_data = OCSPTelemetryData()
208208
telemetry_data.set_cache_enabled(self.OCSP_CACHE_SERVER.CACHE_SERVER_ENABLED)
209-
telemetry_data.set_insecure_mode(False)
209+
telemetry_data.set_disable_ocsp_checks(False)
210210
telemetry_data.set_sfc_peer_host(hostname)
211211
telemetry_data.set_fail_open(self.is_enabled_fail_open())
212212

src/snowflake/connector/aio/_ssl_connector.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ async def connect(
5353
and protocol is not None
5454
and not getattr(protocol, "_snowflake_ocsp_validated", False)
5555
):
56-
if self._snowflake_ocsp_mode == OCSPMode.INSECURE:
57-
log.info(
58-
"THIS CONNECTION IS IN INSECURE "
59-
"MODE. IT MEANS THE CERTIFICATE WILL BE "
60-
"VALIDATED BUT THE CERTIFICATE REVOCATION "
61-
"STATUS WILL NOT BE CHECKED."
56+
if self._snowflake_ocsp_mode == OCSPMode.DISABLE_OCSP_CHECKS:
57+
log.debug(
58+
"This connection does not perform OCSP checks. "
59+
"Revocation status of the certificate will not be checked against OCSP Responder."
6260
)
6361
else:
6462
await self.validate_ocsp(req.url.host, protocol)

0 commit comments

Comments
 (0)