Python API SDK SSL: CERTIFICATE_VERIFY_FAILED Error

S_M_22
S_M_22
edited 08/18/23 in API & Developers

I am running into this error trying to connect smartsheet api via python sdk and getting this error on a mac book pro:

smartsheet.exceptions.HttpError: (SSLError(MaxRetryError("HTTPSConnectionPool(host='api.smartsheet.com', port=443): Max retries exceeded with url: /2.0/sheets?pageSize=300&includeAll=False (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))",),), 'SSL handshake error, old CA bundle or old OpenSSL?')

Any help would be great!

Answers

  • Genevieve P.
    Genevieve P. Employee Admin

    Hi @S_M_22

    Since the error is "SSL: Certificate_Verify_Failed", this error is likely due a non up-to-date environment.

    I believe Python on MacOS comes with its own private copy of OpenSSL. This means the trust certificates in the system may no longer be used as defaults by the Python ssl module. To fix that, you may need to install a certifi package in your system.

    I found this thread on StackOverflow which may help you. If it hasn't, please reach out to your IT department as they will need to work out what's happening between Python and your Mac.

    Cheers,

    Genevieve

  • anike
    anike ✭✭
    edited 08/18/23

    Hey,

    I totally feel your frustration, as I've encountered this SSL certificate issue before. It can be quite a roadblock, but don't worry, we'll get through this together!

    First off, big shoutout to the author for bringing up this problem. Connecting to APIs can sometimes be a headache, especially when SSL handshake errors jump in the way. From what I've experienced, this issue usually crops up when your Python environment isn't playing nice with the SSL certificates.

    Now, onto a solution! It seems like your Mac's SSL certificates might need a refresh. I'd suggest installing the certifi package – it helps your Python environment find up-to-date certificates. Just a quick pip install away, and you might see that SSL handshake error disappear.

    I've personally battled with similar SSL errors, and often it's about keeping everything updated and in sync. So, my fellow coder, give the certifi solution a shot. You'll likely find yourself back on track with your Smartsheet API endeavors.

    Greetings from a cutting-edge technology developer! Explore the realm of cool and contemporary tech at https://andersenlab.de/blueprint/php-vs-python-for-web-development 😏. Feel free to get in touch with me.