How to check X509 certificate in python, including CRL check?

I am trying to verify an X509 certificate using python. In particular, I need to check the CRL when I do this.

Now you can use m2crypto for this, but I can not find the option corresponding to openssl -crl_check or -crl_check_all.

Alternatively, I could use the channel directly and call openssl:

p1 = Popen(["openssl", "verify", "-CApath", capath, "-crl_check_all"], 
           stdin = PIPE, stdout = PIPE, stderr = PIPE)

message, error = p1.communicate(certificate)
exit_code = p1.returncode

However, it seems like the openssl check always returns exit code 0, so I will need to somehow compare the strings to determine if the check is successful, which I would not want to do.

Did I miss something simple here?

Thank.

+5
source share
3 answers

Alright, alright what I did:

p1 = Popen(["openssl", "verify", "-CApath", capath, "-crl_check_all"], 
           stdin = PIPE, stdout = PIPE, stderr = PIPE)

message, error = p1.communicate(certificate)

verified = ("OK" in message and not "error" in message)

, . , , . C , openssl .

- , , .

+1

openssl verify.c, 0 , . openssl : python .

0

All Articles