I have a very strange issue with ssl library in Python.
My Python version is 3.5.2.
All I'm doing is running the following three lines of code:
import ssl
ssl_context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
ssl_context.load_cert_chain(certfile=r'C:\_del\publicCert.pem',
keyfile=r'C:\_del\privateKey.pem')
Calling the last line throws an error:
OSError: [Errno 9] Bad file descriptor
I was trying to find information on ssl library and "Bad file descriptor" error, but all I found were issues where connection was already established. I think in my case, it must have something to do either with the settings or the files themselves, since when I create_default_context and load_cert_chain there's no connection to the server yet.
My certificate/key files have the following structure:
privateKey.pem
Bag Attributes
localKeyID: ...
friendlyName: ...
Key Attributes: <No Attributes>
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: ...
DEK-Info: ...
...key content...
-----END RSA PRIVATE KEY-----
publicCert.pem
Bag Attributes
localKeyID: ...
friendlyName: ...
subject=...
issuer=...
-----BEGIN CERTIFICATE-----
... certificate content ...
-----END CERTIFICATE-----
Has anyone encountered such issue? Is it possible that the certificate I'm using is not compatible with OpenSSL version (0.9.8r)? The certificate uses SHA256 algorithm.
Additional information:
When I'm using openssl and try to verify the certificate PEM file:
openssl verify C:\_del\certfile.pem
I'm getting the following error:
error 20 at 0 depth lookup:unable to get local issuer certificate
publicCert.certmust be a singe file of formatPEM. do you know what is format of yourcertfile?