Reputation: 371
I have different error output for Linux and Windows (both use python 3.7.3 and PyOpenSSL 19.0).
response = s.post(url=my_url,
data=json.dumps(data.__dict__),
timeout=15,
headers={'accept': 'application/json', 'content-type':'application/json'},
cert=(str(Path(__file__).parents[1]) + "/my_key.key",str(Path(__file__).parents[1]) + "/my_cert.crt"),
verify=False)
And I've installed OpenSSL
and wrappers for Python on both systems.
On Windows:
OpenSSL.SSL.Error: [('PEM routines', 'get_name', 'no start line'), ('SSL routines', 'use_certificate_chain_file', 'PEM lib')]
On Linux
[('PEM routines', 'get_name', 'no start line'), ('SSL routines', 'SSL_CTX_use_PrivateKey_file', 'PEM lib')]
And I'm sure that cert and key are OK, because I've tried a curl
request.
What causes this error?
Upvotes: 0
Views: 6408
Reputation: 14148
Your certificate and key files are in the incorrect format. From the error, it looks like it wants a the certificate and key in the PEM format.
My guess is that your certificate and key are in DER format. Try converting the files from DER to PEM.
See https://serverfault.com/questions/254627/how-do-i-convert-a-cer-certificate-to-pem as a example of how to convert CER to PEM format.
Upvotes: 2