Closed YPOC closed 4 years ago
The requests_pkcs12 library is essentially just glue code between the requests library and the OpenSSL library. For parsing issues, it will return whichever exception was thrown by (py)OpenSSL.
I'm hesitant to modify exceptions on their way through requests_pkcs12, as that may break expectations of other developers who are more into all that requests and OpenSSL business. This might also break existing code.
I wonder what makes catching those exceptions such a pain for you. Please feel free to provide a code snippet of your error handling code here. Maybe there is some way to simplify it.
Thanks, pointing me to pyOpenSSL already helped me. I thought the raised error was a general exception and didn't bother to check its type. Now I can from OpenSSL import crypto
and just catch any crypto.Error
. It doesn't necessarily tell me that the password is incorrect, but that's probably a good thing. Thank you!
When specifying an incorrect password for the certificate requests_pkcs12 will raise a general exception Error([('PKCS12 routines', 'PKCS12_parse', 'mac verify failure')]), which is a pain to catch. Would it be possible to use a more specific exception, or one of requests.exceptions? Also I couldn't find any information about which exceptions can be raised. Or is there any easy way to handle that exception I don't know about?