crypto.X509Store load_locations() do nothing

361 views Asked by At

I want to add trusted certificates from directory. I tried to use:

store = crypto.X509Store()
store.load_locations(None, ".\\certificates")

and then

context = crypto.X509StoreContext(self.store, cert)

where cert is my certificate which I want to verify.

It does completely nothing. I tried to open this directory. I worked. I read those certificates. It worked too. But when I was trying verify my cert by context.verify_certificate() it failed. What do I wrong?

1

There are 1 answers

0
Antoine On

If you check the documentation for X509StoreContext objects, you will see that you need to execute either the "get_verified_chain()" or the "verify_certificate()" method in order to do the verification. So, adding something around those lines should execute your verification :

context = crypto.X509StoreContext(self.store, cert)
try:
  checked_chn = store_ctxt.verify_certificate()
except crypto.X509StoreContextError as e:
  print(e)