Totopoildo
Totopoildo

Reputation: 49

Verify SSL certificate with Requests

I'm trying to verify SSL but it doesn't work.

  1. I went on the confidential website I wanna get, on my browser.
  2. On Chrome I've clicked on the locker > certificates > Details > copy in a file > base 64 > certif.cer

My code is :

test = requests.get('https://confidential.xx/', verify='certif.cer')

And the error is :

File "C:\Users\xxxxx\Downloads\WinPython\WPy64-3850\python-3.8.5.amd64\lib\site-packages\requests\adapters.py", line 514, in send raise SSLError(e, request=request)

SSLError: HTTPSConnectionPool(host='xxxxx', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)')))

I don't wanna use verify=False which works but not securised.

I have tried with and without the proxies, same error...

I need to make this working, how make this code working please ?

Upvotes: 4

Views: 4474

Answers (1)

Andrej Kesely
Andrej Kesely

Reputation: 195438

To make requests not complain about valid certificate, the certificate supplied to verify= must contain any intermediate certificates. To download full chain, you can use Firefox (screenshots):

Click on page info:

enter image description here


Then download full PEM chain:

enter image description here

Upvotes: 6

Related Questions