I have two certificates, a root.crt that was used to sign client.crt.
I want to verify that the client.crt was indeed signed by root.key.
Using openssl on terminal, it works like this:
$ openssl verify -CAfile root.crt client.crt
> client.crt: OK
However using pyOpenSSL - following the documentation and this blog post - I tried something like this:
client_cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, file('client.crt').read())
root_cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, file('root.crt').read())
store = OpenSSL.crypto.X509Store()
store.add_cert(root_cert)
ctx = OpenSSL.crypto.X509StoreContext(store, client_cert)
ctx.verify_certificate()
I get this error:
> X509StoreContextError: [2, 1, 'unable to get issuer certificate']
What am I missing?