@@ -563,7 +563,9 @@ def get_calling_module() -> str:
563
563
564
564
if credentials_provider .split ("." )[- 1 ] in ("IdpTokenAuthPlugin" ,):
565
565
redshift_native_auth = True
566
- self .set_idc_plugins_params (init_params , credentials_provider , identity_namespace , token_type )
566
+ self .set_idc_plugins_params (
567
+ init_params , credentials_provider , identity_namespace , token_type
568
+ )
567
569
568
570
if redshift_native_auth and provider_name :
569
571
init_params ["provider_name" ] = provider_name
@@ -633,16 +635,18 @@ def get_calling_module() -> str:
633
635
# create ssl connection with Redshift CA certificates and check the hostname
634
636
if ssl is True :
635
637
try :
636
- from ssl import PROTOCOL_TLS_CLIENT , SSLContext
638
+ from ssl import CERT_REQUIRED , SSLContext
639
+
640
+ # ssl_context = ssl.create_default_context()
637
641
638
642
path = os .path .abspath (__file__ )
639
643
if os .name == "nt" :
640
644
path = "\\ " .join (path .split ("\\ " )[:- 1 ]) + "\\ files\\ redshift-ca-bundle.crt"
641
645
else :
642
646
path = "/" .join (path .split ("/" )[:- 1 ]) + "/files/redshift-ca-bundle.crt"
643
647
644
- # The protocol enables CERT_REQUIRED and check_hostname by default.
645
- ssl_context : SSLContext = SSLContext ( protocol = PROTOCOL_TLS_CLIENT )
648
+ ssl_context : SSLContext = SSLContext ()
649
+ ssl_context . verify_mode = CERT_REQUIRED
646
650
ssl_context .load_default_certs ()
647
651
_logger .debug ("try to load Redshift CA certs from location %s" , path )
648
652
ssl_context .load_verify_locations (path )
@@ -658,13 +662,12 @@ def get_calling_module() -> str:
658
662
659
663
if sslmode == "verify-ca" :
660
664
_logger .debug ("applying sslmode=%s to socket" , sslmode )
661
- ssl_context .check_hostname = False
662
665
self ._usock = ssl_context .wrap_socket (self ._usock )
663
666
elif sslmode == "verify-full" :
664
667
_logger .debug ("applying sslmode=%s to socket and force check_hostname" , sslmode )
668
+ ssl_context .check_hostname = True
665
669
self ._usock = ssl_context .wrap_socket (self ._usock , server_hostname = host )
666
670
else :
667
- ssl_context .check_hostname = False
668
671
_logger .debug ("unknown sslmode=%s is ignored" , sslmode )
669
672
_logger .debug ("Socket SSL details: %s" , self ._usock .cipher ()) # type: ignore
670
673
0 commit comments