python-requestsclient-certificatespempkcs#12p12

Python Requests fails to get successful response with (converted) client cert


I’m trying to access an endpoint, which requires a client cert. I’m starting from a .p12, which I was able to quickly import to Google Chrome, and can successfully access the endpoint. So the client certificate and endpoint are compatible.

However, I’m struggling to get Python Requests module (with Python 2.7) to successfully access the same endpoint.

My steps have been:

My PEM file contains three sets of -----BEGIN CERTIFICATE-----, and then -----BEGIN PRIVATE KEY-----. All 4 BEGINs are preceded by Bag Attributes – removing these lines doesn’t make a difference.

I'm doing the key creation with a Ubuntu VM, but running the Python from a Windows machine - not sure if this makes a difference.

I’d welcome any ideas; particularly to understand if the issue is around the conversion to PEM, or if it’s with the request call.


Solution

  • I found https://gist.github.com/erikbern/756b1d8df2d1487497d29b90e81f8068, with the delete=False param as suggested in those comments, and pyOpenSSL, now works.