How can I resolve this SSL error which occurrs when calling databricks-sql-connector/databricks.sql.connect() from my python app?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 12:49 PM
Error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)
> python --version
Python 3.10.4
This error seems to be coming from the thrift backend. I suspect but have not confirmed that the python version is involved. This app was previously able to connect under a configuration that used python 3.8.
I'd prefer not to use self-signed certificates. Any help would be appreciated!
- Labels:
-
SSL Error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 07:21 PM
@Kaniz Fatma Thanks for this workaround. Ultimately I do want to verify the certificates so I'd be interested in hearing about any solutions that would allow that as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 12:16 PM
@Matt Munz Were you ever able to find a solution to this issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2022 09:44 AM
I have the same issue and tried the solution mentioned above. It still did not work. I am getting below error
Error: ('HY000', '[HY000] [Simba][ThriftExtension] (14) Unexpected response from server during a HTTP connection: SSL_connect: certificate verify failed. (14) (SQLDriverConnect)')
I am on Jupyterhub running on Linux
import pyodbc
import ssl
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
# Legacy Python that doesn't verify HTTPS certificates by default
pass
else:
# Handle target environment that doesn't support HTTPS verification
ssl._create_default_https_context = _create_unverified_https_context
conn = pyodbc.connect("Driver=/opt/simba/spark/lib/64/libsparkodbc_sb64.so;" +
"HOST=;" +
"PORT=443;" +
"Schema=default;" +
"SparkServerType=3;" +
"AuthMech=3;" +
"UID=token;" +
"PWD=;" +
"ThriftTransport=2;" +
"SSL=1;" +
"HTTPPath=;" +
"ssl_ca=rootdbcert.cer;" +
"sslverify=0",
autocommit=True)
Where should the SSL certificate reside? I uploaded it to the same project folder where the python script is running. I gave the drive path mentioned in
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 10:01 PM
One way to resolve this could be to ensure your connection values in are surrounded by quotes.
- host: "hostname.databricks.com" # Required
- http_path: "/sql/1.0/warehouses/aaaabbbccc"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 09:20 PM
I have just found a way😁
Try to creating an SSL context without certificate verification and then to accomplish this, use the command given below:
import ssl
context = ssl._create_unverified_context()
urllib.request.urlopen(req,context=context)
I have tried some steps from here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 04:17 AM
You can set up an SSL context that skips certificate verification with the following command:
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
I have followed some steps from this source.

