I want to write a piece of code which will load a certificate and its key and use them to set up HTTPS.
I encountered the problem of an RSA key which requires a passphrase: if the key requires a passphrase and I don't pass it to the password
argument of ssl.load_certs_chain, the code will hang waiting for user to prompt the passphrase.
What I would like to do instead is to either fail when the code tries to load the key or detect from the key if it needs a passphrase or not.
I tried to put a default value "-"
to password
paramter of ssl.load_cert_chain
in order to get an error of "wrong password" if the key required a passphrase, but I only get this output
ssl.SSLError: [SSL] PEM lib (_ssl.c:4065)
which is meaningless. There is no details about the exception
From the docs you linked:
You could pass a function of your own that raises a custom exception if the password fails.