@@ -563,9 +563,7 @@ def get_calling_module() -> str:
563563
564564 if credentials_provider .split ("." )[- 1 ] in ("IdpTokenAuthPlugin" ,):
565565 redshift_native_auth = True
566- self .set_idc_plugins_params (
567- init_params , credentials_provider , identity_namespace , token_type
568- )
566+ self .set_idc_plugins_params (init_params , credentials_provider , identity_namespace , token_type )
569567
570568 if redshift_native_auth and provider_name :
571569 init_params ["provider_name" ] = provider_name
@@ -635,18 +633,16 @@ def get_calling_module() -> str:
635633 # create ssl connection with Redshift CA certificates and check the hostname
636634 if ssl is True :
637635 try :
638- from ssl import CERT_REQUIRED , SSLContext
639-
640- # ssl_context = ssl.create_default_context()
636+ from ssl import PROTOCOL_TLS_CLIENT , SSLContext
641637
642638 path = os .path .abspath (__file__ )
643639 if os .name == "nt" :
644640 path = "\\ " .join (path .split ("\\ " )[:- 1 ]) + "\\ files\\ redshift-ca-bundle.crt"
645641 else :
646642 path = "/" .join (path .split ("/" )[:- 1 ]) + "/files/redshift-ca-bundle.crt"
647643
648- ssl_context : SSLContext = SSLContext ()
649- ssl_context . verify_mode = CERT_REQUIRED
644+ # The protocol enables CERT_REQUIRED and check_hostname by default.
645+ ssl_context : SSLContext = SSLContext ( protocol = PROTOCOL_TLS_CLIENT )
650646 ssl_context .load_default_certs ()
651647 _logger .debug ("try to load Redshift CA certs from location %s" , path )
652648 ssl_context .load_verify_locations (path )
@@ -662,12 +658,13 @@ def get_calling_module() -> str:
662658
663659 if sslmode == "verify-ca" :
664660 _logger .debug ("applying sslmode=%s to socket" , sslmode )
661+ ssl_context .check_hostname = False
665662 self ._usock = ssl_context .wrap_socket (self ._usock )
666663 elif sslmode == "verify-full" :
667664 _logger .debug ("applying sslmode=%s to socket and force check_hostname" , sslmode )
668- ssl_context .check_hostname = True
669665 self ._usock = ssl_context .wrap_socket (self ._usock , server_hostname = host )
670666 else :
667+ ssl_context .check_hostname = False
671668 _logger .debug ("unknown sslmode=%s is ignored" , sslmode )
672669 _logger .debug ("Socket SSL details: %s" , self ._usock .cipher ()) # type: ignore
673670
0 commit comments