Search code examples
pythonssldatabricksdelta-sharing

Python Delta_Sharing SSL certificate verify failed: self signed cert


I've not been able to find an answer that fixes this SSL error for delta_sharing

import delta_sharing
import pandas as pd
delta_sharing.SharingClient("<PersonalTokenHere>").list_all_tables()

This takes several minutes and then complains Max retries exceeded with URL: ... (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)')))

I have no problem connecting to this data source using PowerBI or RStudio (delta.sharing package), so the issue seems to be specific to Python.

Does anyone know how to fix this for for delta_sharing?

I have tried importing requests and setting session.verify = False which was suggested for http requests and it doesn't help.

There is a delta-io example access token at https://github.com/delta-io/delta-sharing (Accessing Shared Data section in documentation), this gives me the same error when I try connect.


Solution

  • I was able to follow instructions here to resolve: https://community.openai.com/t/ssl-certificate-verify-failed/32442/39

    Using this to locate the python certificate file:

    import certifi
    certifi.where()
    
    1. Going to full URL in the .share file in Chrome
    2. Right clicking the lock-icon in the browser
    3. Selecting Connection is secure -> Certificate is valid
    4. Clicking on Root CA (top of hierarchy)
    5. Click export
    6. Opening the .pem file
    7. Pasting the certificate into the .pem file located by certifi.where()