Python-requests send certificate

Viewed 1031

I have two files one called public_key.pem and another called certificate.crt

I extracted .cer file from browser than used

openssl x509 -inform DER -in somefile.cer -out certificate.crt

then did

openssl x509 -inform der -pubkey -noout -in somefile.cer > public_key.pem

Now I am trying to pass certificate.crt and public_key.pem file to my python-requests.

r = requests.get('someurl.com', verify='public_key.pem', cert='certificate.crt')

I get the following error:Caused by SSLError(SSLError(136, '[X509: NO_CERTIFICATE_OR_CRL_FOUND] no certificate or crl found (_ssl.c:4263)')))

This is certificate.crt file

-----BEGIN CERTIFICATE-----
somecert
-----END CERTIFICATE-----

and this is public_key.pem

-----BEGIN PUBLIC KEY-----
pubkey
-----END PUBLIC KEY-----

I have also tried the following:

response = r.get('someurl', cert=('certificate.crt','public_key.pem'), headers=headers, params=params)

I get the following error:

Caused by SSLError(SSLError(9, '[SSL] PEM lib (_ssl.c:4043)')))
0 Answers
Related