55import time
66import uuid
77import threading
8- from ssl import CERT_NONE , CERT_REQUIRED , create_default_context
98from typing import List , Union
109
1110import pyarrow
3635 convert_decimals_in_arrow_table ,
3736 convert_column_based_set_to_arrow_table ,
3837)
38+ from databricks .sql .types import SSLOptions
3939
4040logger = logging .getLogger (__name__ )
4141
@@ -85,6 +85,7 @@ def __init__(
8585 http_path : str ,
8686 http_headers ,
8787 auth_provider : AuthProvider ,
88+ ssl_options : SSLOptions ,
8889 staging_allowed_local_path : Union [None , str , List [str ]] = None ,
8990 ** kwargs ,
9091 ):
@@ -93,16 +94,6 @@ def __init__(
9394 # Tag to add to User-Agent header. For use by partners.
9495 # _username, _password
9596 # Username and password Basic authentication (no official support)
96- # _tls_no_verify
97- # Set to True (Boolean) to completely disable SSL verification.
98- # _tls_verify_hostname
99- # Set to False (Boolean) to disable SSL hostname verification, but check certificate.
100- # _tls_trusted_ca_file
101- # Set to the path of the file containing trusted CA certificates for server certificate
102- # verification. If not provide, uses system truststore.
103- # _tls_client_cert_file, _tls_client_cert_key_file, _tls_client_cert_key_password
104- # Set client SSL certificate.
105- # See https://docs.python.org/3/library/ssl.html#ssl.SSLContext.load_cert_chain
10697 # _connection_uri
10798 # Overrides server_hostname and http_path.
10899 # RETRY/ATTEMPT POLICY
@@ -162,29 +153,7 @@ def __init__(
162153 # Cloud fetch
163154 self .max_download_threads = kwargs .get ("max_download_threads" , 10 )
164155
165- # Configure tls context
166- ssl_context = create_default_context (cafile = kwargs .get ("_tls_trusted_ca_file" ))
167- if kwargs .get ("_tls_no_verify" ) is True :
168- ssl_context .check_hostname = False
169- ssl_context .verify_mode = CERT_NONE
170- elif kwargs .get ("_tls_verify_hostname" ) is False :
171- ssl_context .check_hostname = False
172- ssl_context .verify_mode = CERT_REQUIRED
173- else :
174- ssl_context .check_hostname = True
175- ssl_context .verify_mode = CERT_REQUIRED
176-
177- tls_client_cert_file = kwargs .get ("_tls_client_cert_file" )
178- tls_client_cert_key_file = kwargs .get ("_tls_client_cert_key_file" )
179- tls_client_cert_key_password = kwargs .get ("_tls_client_cert_key_password" )
180- if tls_client_cert_file :
181- ssl_context .load_cert_chain (
182- certfile = tls_client_cert_file ,
183- keyfile = tls_client_cert_key_file ,
184- password = tls_client_cert_key_password ,
185- )
186-
187- self ._ssl_context = ssl_context
156+ self ._ssl_options = ssl_options
188157
189158 self ._auth_provider = auth_provider
190159
@@ -225,7 +194,7 @@ def __init__(
225194 self ._transport = databricks .sql .auth .thrift_http_client .THttpClient (
226195 auth_provider = self ._auth_provider ,
227196 uri_or_host = uri ,
228- ssl_context = self ._ssl_context ,
197+ ssl_options = self ._ssl_options ,
229198 ** additional_transport_args , # type: ignore
230199 )
231200
@@ -776,7 +745,7 @@ def _results_message_to_execute_response(self, resp, operation_state):
776745 max_download_threads = self .max_download_threads ,
777746 lz4_compressed = lz4_compressed ,
778747 description = description ,
779- ssl_context = self ._ssl_context ,
748+ ssl_options = self ._ssl_options ,
780749 )
781750 else :
782751 arrow_queue_opt = None
@@ -1008,7 +977,7 @@ def fetch_results(
1008977 max_download_threads = self .max_download_threads ,
1009978 lz4_compressed = lz4_compressed ,
1010979 description = description ,
1011- ssl_context = self ._ssl_context ,
980+ ssl_options = self ._ssl_options ,
1012981 )
1013982
1014983 return queue , resp .hasMoreRows
0 commit comments