0

I'm trying to access https but I got "certificate verify failed". Here's my code:

from bs4 import BeautifulSoup
import requests
url = 'https://covidlive.com.au/report/daily-cases/vic'
html = requests.get(url).content
        
bs = BeautifulSoup(html, 'html.parser')

The error I received:

SSLError: HTTPSConnectionPool(host='covidlive.com.au', port=443): Max retries exceeded with url: /report/daily-cases/vic (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)')))

If I change my code to:

html = requests.get(url,verify=False).content

I won't see the error but this is not what I want Per the discussion here: Python SSL certificate verify error , I believe my case needs to "add CA in the trusted list for the requests library". And the example code is:

r = requests.post(url, data=data, verify='/path/to/public_key.pem')

I'm using win10. I checked the information here: https://www.globalsign.com/en/blog/how-to-view-ssl-certificate-details But still I don't know how can I find the .pem file on my PC.

Can you please help?

Ginger_Chacha
  • 317
  • 1
  • 11
  • My understanding is I can open the website using any of my browser and there's no error which means my browser has had the access to the .pem file, or any type of CA. If i inlcude that .pem file to my Python code it should be fine. But where is the .pem file? – Ginger_Chacha Dec 15 '21 at 19:32
  • All clients need the _root certificate_; python uses a PEM-format file whose name may or may not end in .pem, but browsers use different formats adn stores. The actual filename doesn't matter, but calling it a public key is deceptive. That server gives both me and SSLLabs a valid chain under Comodo/AAA _not_ including self-signed; does your DNS resolve it to 43.250.140.32 and does your internet connection go through any kind of monitoring, firewall, or proxy? Try `openssl s_client -connect covidlive.com.au:443` and if below 1.1.1 add `-servername covidlive.com.au` – dave_thompson_085 Dec 15 '21 at 20:56
  • On my platform your code executes without raising the exception. – President James K. Polk Dec 15 '21 at 21:10

0 Answers0