Coding⏱️ 3 min read📅 2026-06-03

How to Fix: Scraping: SSL: CERTIFICATE_VERIFY_FAILED error for http://en.wikipedia.org

The CERTIFICATE_VERIFY_FAILED error occurs when the SSL certificate of a website is not trusted by your system. In this case, you need to add the Wikipedia's SSL certificate to your system's trusted certificates.

Quick Answer: You can do this by adding the following line of code before making the HTTP request: ssl._create_default_https_context = ssl._create_default_https_context + ssl.CERT_REQUIRED

The SSL: CERTIFICATE_VERIFY_FAILED error occurs when the Python script is unable to verify the SSL certificate of the target website. This issue affects web scraping scripts that attempt to access websites using HTTPS protocol.

This error can be frustrating for web scrapers because it prevents them from accessing the desired information, leading to incomplete or inaccurate data collection.

💡 Why You Are Getting This Error

  • The primary reason for this error is the mismatch between the expected and actual SSL certificates. When the Python script is configured to use a specific SSL certificate, it may not match the one used by the target website.
  • An alternative cause of this error could be the presence of self-signed or invalid SSL certificates on the target website.

🔧 Proven Troubleshooting Steps

Enabling Custom Certificate Verification

  1. Step 1: Step 1: Import the required libraries. The `ssl` library is used to verify the SSL certificate.
  2. Step 2: Step 2: Create a custom context for verification. This allows you to specify the path to the trusted certificates file or set up a custom verification process.
  3. Step 3: Step 3: Use the custom context when opening the URL. By doing so, you can bypass the default SSL verification and continue with your web scraping script.

Using a Trusted Certificate Authority (CA)

  1. Step 1: Step 1: Obtain an SSL certificate from a trusted CA. This ensures that the target website's SSL certificate is recognized by the Python script.
  2. Step 2: Step 2: Install the obtained SSL certificate on your system or use it in your web scraping script.

✨ Wrapping Up

To resolve the SSL: CERTIFICATE_VERIFY_FAILED error, you can try enabling custom certificate verification using the `ssl` library. Alternatively, obtaining an SSL certificate from a trusted CA and installing it on your system can also help bypass this issue.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions