0
 [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)>

   from urllib import request as urlrequest 

   PROXY_ADDRESS = '212.205.112.162:57205'
   url = 'http://www.showmemyip.com/'

   request = urlrequest.Request(url)    
   request.set_proxy(PROXY_ADDRESS,'http')
   response = urlrequest.urlopen(request)    
   print(response.read().decode('utf8'))

How can I include the ssl certificate in the request?

Thank your for any help

  • 1
    Possible duplicate of [Python Requests throwing SSLError](https://stackoverflow.com/questions/10667960/python-requests-throwing-sslerror) – SACHIN CHAVAN Aug 27 '19 at 13:12

1 Answers1

0

I had the same problem and I struggled for weeks. To include the certifcate:

requests.get("Website", verify ="CertBundle.pem")

To get your certificate open your Internet Explorer and navigate to your website. On the right side next to the url you click on the lock-icon. -> show certificate -> certification path. Here you find the name/names of the certificates you need.

Go to Chrome -> Settings -> data privacy and security -> manage certificates

Now look for your certificate and export it. If you have more then one, create a new text file -> CertBundle.pem and copy the content of the certificates in CertBundle. You only ----BEGIN--- and ----End--- once. Just copy paste it after one another and you are ready to go.

MLAlex
  • 142
  • 10
  • Thank you very much –  Aug 27 '19 at 14:05
  • Now I get this error: requests.exceptions.SSLError: HTTPSConnectionPool(host='mywebsite.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),)) –  Aug 27 '19 at 14:21
  • This means your certificate is not correct. Go back to the certification path. Maybe you are missing one certificate. – MLAlex Aug 27 '19 at 14:27
  • Yes in fact there are 2. I have DST ROOT CA X3 and a certificate called Let's Encrypt Authority X3 in it and inside that the certificate for my website. But the only I can find is the certificate for my website and not the Let's Encrypt Authority X3 –  Aug 27 '19 at 14:44
  • hm thats weird, I´m quite sure you need the first 2 certificates so, DST ROOT CA and Encrypt Authority x3. Did you search in all Tabs? – MLAlex Aug 28 '19 at 06:00
  • Also here is link, maybe it helps you to find them. But as I said, it also took me weeks to do it. Certificates are horrible if you are not a security guy. https://technet.microsoft.com/en-us/windows/ms788967(v=vs.80) – MLAlex Aug 28 '19 at 06:02