5
5
import time
6
6
import uuid
7
7
import threading
8
- from ssl import CERT_NONE , CERT_REQUIRED , create_default_context
9
8
from typing import List , Union
10
9
11
10
import pyarrow
36
35
convert_decimals_in_arrow_table ,
37
36
convert_column_based_set_to_arrow_table ,
38
37
)
38
+ from databricks .sql .types import SSLOptions
39
39
40
40
logger = logging .getLogger (__name__ )
41
41
@@ -85,6 +85,7 @@ def __init__(
85
85
http_path : str ,
86
86
http_headers ,
87
87
auth_provider : AuthProvider ,
88
+ ssl_options : SSLOptions ,
88
89
staging_allowed_local_path : Union [None , str , List [str ]] = None ,
89
90
** kwargs ,
90
91
):
@@ -93,16 +94,6 @@ def __init__(
93
94
# Tag to add to User-Agent header. For use by partners.
94
95
# _username, _password
95
96
# 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
106
97
# _connection_uri
107
98
# Overrides server_hostname and http_path.
108
99
# RETRY/ATTEMPT POLICY
@@ -162,29 +153,7 @@ def __init__(
162
153
# Cloud fetch
163
154
self .max_download_threads = kwargs .get ("max_download_threads" , 10 )
164
155
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
188
157
189
158
self ._auth_provider = auth_provider
190
159
@@ -225,7 +194,7 @@ def __init__(
225
194
self ._transport = databricks .sql .auth .thrift_http_client .THttpClient (
226
195
auth_provider = self ._auth_provider ,
227
196
uri_or_host = uri ,
228
- ssl_context = self ._ssl_context ,
197
+ ssl_options = self ._ssl_options ,
229
198
** additional_transport_args , # type: ignore
230
199
)
231
200
@@ -776,7 +745,7 @@ def _results_message_to_execute_response(self, resp, operation_state):
776
745
max_download_threads = self .max_download_threads ,
777
746
lz4_compressed = lz4_compressed ,
778
747
description = description ,
779
- ssl_context = self ._ssl_context ,
748
+ ssl_options = self ._ssl_options ,
780
749
)
781
750
else :
782
751
arrow_queue_opt = None
@@ -1008,7 +977,7 @@ def fetch_results(
1008
977
max_download_threads = self .max_download_threads ,
1009
978
lz4_compressed = lz4_compressed ,
1010
979
description = description ,
1011
- ssl_context = self ._ssl_context ,
980
+ ssl_options = self ._ssl_options ,
1012
981
)
1013
982
1014
983
return queue , resp .hasMoreRows
0 commit comments