@@ -858,7 +858,7 @@ def __init__(
858858 if os .getenv ("SF_OCSP_FAIL_OPEN" ) is not None :
859859 # failOpen Env Variable is for internal usage/ testing only.
860860 # Using it in production is not advised and not supported.
861- self .FAIL_OPEN = os .getenv ("SF_OCSP_FAIL_OPEN" )
861+ self .FAIL_OPEN = os .getenv ("SF_OCSP_FAIL_OPEN" ). lower () == 'true'
862862 else :
863863 self .FAIL_OPEN = use_fail_open
864864
@@ -893,6 +893,8 @@ def validate(self, hostname, connection, no_exception=False):
893893 """
894894 logger .debug (u'validating certificate: %s' , hostname )
895895
896+ do_retry = SnowflakeOCSP .get_ocsp_retry_choice ()
897+
896898 m = not SnowflakeOCSP .OCSP_WHITELIST .match (hostname )
897899 if m or hostname .startswith ("ocspssd" ):
898900 logger .debug (u'skipping OCSP check: %s' , hostname )
@@ -902,7 +904,7 @@ def validate(self, hostname, connection, no_exception=False):
902904 self .OCSP_CACHE_SERVER .reset_ocsp_endpoint (hostname )
903905
904906 cert_data = self .extract_certificate_chain (connection )
905- return self ._validate (hostname , cert_data , no_exception = no_exception )
907+ return self ._validate (hostname , cert_data , do_retry , no_exception )
906908
907909 def _validate (
908910 self , hostname , cert_data , do_retry = True , no_exception = False ):
@@ -924,6 +926,10 @@ def _validate(
924926 logger .debug ('ok' if not any_err else 'failed' )
925927 return results
926928
929+ @staticmethod
930+ def get_ocsp_retry_choice ():
931+ return os .getenv ("SF_OCSP_DO_RETRY" , "true" ) == "true"
932+
927933 def is_cert_id_in_cache (self , cert_id , subject ):
928934 """
929935 Is OCSP CertID in cache?
@@ -1021,7 +1027,7 @@ def validate_by_direct_connection(self, issuer, subject, hostname=None, do_retry
10211027 logger .debug ("getting OCSP response from CA's OCSP server" )
10221028 ocsp_response = self ._fetch_ocsp_response (req , subject ,
10231029 cert_id , telemetry_data ,
1024- hostname )
1030+ hostname , do_retry )
10251031 else :
10261032 ocsp_url = self .extract_ocsp_url (subject )
10271033 cert_id_enc = self .encode_cert_id_base64 (self .decode_cert_id_key (cert_id ))
0 commit comments