DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Automating Threat Detection Using Python, Kafka, and Real-Time Log Processing
  • Building a Production-Ready MCP Server in Python
  • Data Privacy and Security: A Developer's Guide to Handling Sensitive Data With DuckDB
  • Strengthening Cloud Environments Through Python and SQL Integration

Trending

  • Fact-Checking LLM Outputs Programmatically: Building a Verification Layer That Catches Hallucinations
  • When Angular APIs Return 200 but the Frontend Is Already Failing Users
  • Context Is the New Schema
  • How AI Coding Assistants Are Changing Developer Flow
  1. DZone
  2. Software Design and Architecture
  3. Security
  4. PyCharm Fix for Certificate Verify Failed: Unable To Get Local Issuer Certificate

PyCharm Fix for Certificate Verify Failed: Unable To Get Local Issuer Certificate

This article presents a PyCharm resolution for when a security app like Zscalar makes URLS inaccessible for testing code.

By 
Priyanka Chauhan user avatar
Priyanka Chauhan
·
Jun. 27, 23 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
15.5K Views

Join the DZone community and get the full member experience.

Join For Free

When your organization installs a security monitoring app like Zscaler on your workstation, it could hinder your productivity by blocking many existing third-party apps you have been using for your development or testing deliverables. 

In many cases, once installed, you will have no problem accessing public URLs via browser but will still face challenges when trying to access via terminal or IDE. Although when organizations install security apps, they add company-generated certificates in the system cert, some applications like Java, Python, IDE, NPM, etc. do not use default system cert and have their own custom trust store, which fails to validate Zscaler-generated server certificates, and the TLS connection fails.

Despite going through Zscalar documentation (referenced) on how to add company root CA certificate to these apps (IDE and Python, in this case), IDE failed to establish a successful connection to public URLs and was timing out with an error:

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))

One easy workaround to overcome this would be to set verify=False in your endpoint requests, but I discourage this approach because the verify=False parameter in request library calls is used to disable SSL certificate verification when making HTTPS requests. However, it is generally not recommended to use verify=False unless you have a specific reason to do so. Here are a few reasons why it's not recommended:

  1. Security risks: SSL certificate verification is an essential part of secure communication over the internet. Disabling certificate verification means that your requests are vulnerable to man-in-the-middle attacks, where an attacker can intercept and tamper with the data being transmitted.
  2. The authenticity of the server: SSL certificate verification ensures that you are connecting to the intended server and not an imposter. By disabling verification, you lose the guarantee that you communicate with the correct server, increasing the risk of exposing sensitive information to malicious entities.
  3. Compliance requirements: In certain industries or contexts, there might be regulatory or compliance requirements that mandate SSL certificate verification. Ignoring these requirements can lead to legal or regulatory consequences.
  4. Stability and reliability: Disabling certificate verification may result in connection failures or unreliable communication due to network intermediaries or server configurations. By enabling certificate verification, you can ensure a more stable and reliable connection.

If you encounter issues with SSL certificate verification, it's generally better to address the root cause rather than bypassing it by disabling verification. It's important to prioritize security and integrity when making requests over HTTPS. Disabling SSL certificate verification by using verify=False should be done only when you fully understand the risks involved and have a compelling reason to do so.

Here is a set of step-by-step instructions that helped to overcome without compromising security policy:

  1. Download Zscalar CA root certificate: There are several ways to download the CA root cert depending on if you have Administrative access or not and which platform you have on your workstation. Here, I will show two ways to get methods to do so:
    1. On Mac: 
      1. Find the certificate: On MacOS, SSL certificates are accessible from the KeyChain Access app under Applications → Utilities → KeyChain Access.  
      2. Under  system->“Certificates,” look for the Zscaler certificate
      3. Export the certificate to a .pem file: Right-click and use the KeyChain Access app’s export option. Make sure to choose the .pem format.
    2. From Browser: 
      1. Find the certificate: Open and click on the lock icon at the beginning:Find the certificate
      2. Click on the option "Connection is secure"Click on the option "Connection is secure
      3. Click on "Connection is valid" Click on "Connection is valid"
      4. Switch to the "detail" tab and click on root certificate ->export(at the bottom), save the cert into .cer format
      5. Execute the below command from shell to convert .cer to .pem format : openssl x509 -in mycert.crt -out mycert.pem -outform PEM
    3. Add .env file under the root directory of the project in IDE (PyCharm) and add env variable in it: REQUESTS_CA_BUNDLE=/<full path to .pem CA root cert on your workstation>/

I hope the solution suggested saves some of your time when you run into such an issue.

Integrated development environment PyCharm security Error code Python (language)

Opinions expressed by DZone contributors are their own.

Related

  • Automating Threat Detection Using Python, Kafka, and Real-Time Log Processing
  • Building a Production-Ready MCP Server in Python
  • Data Privacy and Security: A Developer's Guide to Handling Sensitive Data With DuckDB
  • Strengthening Cloud Environments Through Python and SQL Integration

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook