Python API SDK SSL: CERTIFICATE_VERIFY_FAILED Error

Options
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

  • 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

    Need more information? πŸ‘€ | Help and Learning Center

    こんにけは (Konnichiwa), Hallo, Hola, Bonjour, OlΓ‘, Ciao!πŸ‘‹ | Global Discussions

  • 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.

  • This content has been removed.
  • jp_mehta
    jp_mehta ✭✭
    edited 07/29/24

    The error indicates an SSL certificate verification issue when connecting to the Smartsheet API, often due to an outdated CA bundle or OpenSSL version. To resolve this on your MacBook Pro, first, update the certifi package by running pip install --upgrade certifi. Additionally, ensure your OpenSSL is up to date by using Homebrew: brew update and brew upgrade openssl. Further i am mentioning one article that can be useful for you :)

    https://cheapsslweb.com/blog/ssl-certificate-verify-failed-error-in-python/ Hope this will work, Cheers!

  • This content has been removed.
  • This content has been removed.
  • This content has been removed.
  • The error you're encountering is related to SSL certificate verification failure when your Python code tries to connect to the Smartsheet API. This is commonly caused by issues with outdated SSL certificates, OpenSSL, or your local environment configuration.

    Here’s what you can try to resolve the issue:

    1. Update Your macOS SSL Certificates: Sometimes, the local system’s certificate bundle can be outdated. Ensure that your system certificates are up-to-date:
      • Open the Keychain Access app on your Mac.
      • Under the System Roots section, ensure the certificates are up-to-date.
    2. Upgrade Python and SSL Dependencies: If you're using an older version of Python or OpenSSL, consider upgrading them.
    3. Upgrade requests Library: The requests library, which is commonly used in SDKs for HTTP connections, might also need an update:
    4. Reinstall the Python SSL Module: Sometimes Python’s SSL module can get misconfigured
    5. Disable SSL Verification: If you need a quick fix and can work without SSL verification
    6. Verify Your OpenSSL: The error mentions "old OpenSSL." Verify if your OpenSSL version is up to date
NEW Smartsheet API Documentation - bookmark the updated link! https://developers.smartsheet.com