vendredi 1 juillet 2016

Python Requests Library: SSL_CTX_use_PrivateKey_file


I'm using the python Requests library to do a POST HTTPS request and authenticate with a certificate and key using the following code:

sess = requests.Session()
 xml = """<?xml version='1.0'?><methodCall><methodName>xxx</methodName><params>
          <param><value><string>xxx</string></value></param>
          <param><value><string>xxx</string></value></param></params></methodCall>"""
response = sess.post('https://x.x.x.x/xx/xx/', data=xml, cert=("/mypath/cert.pem", "/mypath/key.pem"))

This is the error I receive:

requests.exceptions.SSLError: [Errno 336265218] _ssl.c:351: error:140B0002:SSL routines:SSL_CTX_use_PrivateKey_file:system lib

I'm certain I have a PEM encoded certificate because when I view the certificate I see this: -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----

When I view key.pem, I see this: -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY----- so it must be PEM.

The path to cert.pem and key.pem is correct.

Any idea on what my problem is?


Aucun commentaire:

Enregistrer un commentaire