"SSLError SSL: CERTIFICATE_VERIFY_FAILED" when downloading a bulk file.

Akechi Sato
Akechi Sato Explorer
edited 9:22AM in CFS Bulk File/TM3

Hi team,

I cannot download a bulk file via Python. The code returns "SSLError SSL: CERTIFICATE_VERIFY_FAILED" message to me.

Caught exception: HTTPSConnectionPool(host='s3.amazonaws.com', port=443): 
Max retries exceeded with url: /xxxx (Caused by SSLError(SSLCertVerificationError
(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)')))
Tagged:

Answers

  • Hello @Akechi Sato

    The error message [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate indicates that your Python application tries to make a HTTPS connection, but the Python cannot verify SSL certificate of the server. This is most likely the proxy or firewall issue that blocks the Python SSL certificate verification process. The example scenario is ZScaler blocks the process.

    There are two workarounds as follows:

    Work Around 1: Set your proxy/firewall certificate file to the Python call.

    You should export your Proxy/Firewall certificate file (please contact your IT Network team, not LSEG Developer Relations), and then pass it to the Python library that makes HTTPS request.

    Example with ZScaler and Python Requests library

    lib_cert = 'C:\Projects\Code\GenericCFS_Bulk_Project\cert\zscaler.crt.pem'

    try:
    bulkFile_response = polling2.poll(lambda: requests.get(file_url, allow_redirects=False, verify= lib_cert),
    step = 10,
    poll_forever = True,
    check_success= test_result)
    except requests.exceptions.RequestException as exp:
    print(f'Caught exception: {exp}')

    Work Around 2: Disable SSL verification (Not Recommend for Production)

    Set verify = false on the requests library calls. This work around is not recommended on the Production environment.

    try:
    bulkFile_response = polling2.poll(lambda: requests.get(file_url, allow_redirects=False, verify= False),
    step = 10,
    poll_forever = True,
    check_success= test_result)
    except requests.exceptions.RequestException as exp:
    print(f'Caught exception: {exp}')

    I hope this helps.