M2Crypto: X509.CRL
Peter Schmiedeskamp <[email protected]>
| Newsgroups | gmane.comp.python.cryptography |
|---|---|
| Message-ID | <LISTSERV%[email protected]> |
Hello, I'm attempting to use the M2Crypto library to do something relatively simple. I'm using it to verify a SHA1 digest of a file. Here is the algorithm I'm using: Sign the file: 1. Intranet root CA signs & revokes certificates. Also maintains a CRL. This is done on the command line with the OpenSSL command line tools. 2. The x.509 certificate used to verify the digest of a file is generated with OpenSSL on the command line and is certified by the root CA. 3. An SHA1 hash is generated for the file "foo.data", and the digest is encrypted with the private key counterpart to the public key in the x.509 cert. This is also done with the OpenSSL command line tools. Verify the file: 1. With M2Crypto instantiate two X509.X509 objects: "rootcacert" and "mycert". The client has the root CA's certificate distributed out of band. 2. Verify that "mycert" is signed by the root CA. 3. Instantiate an X509.CRL object using the root CA's CRL pem file. 4. Verify that "mycert" is not in the CRL. 5. Verify that the time is neither before the get_not_before nor after the get_not_after. 6. Generate SHA1 hash of "foo.data" using python's built-in SHA1 module. 7. Decrypt the SHA1 hash with the "mycert" public key. Compare with the generated SHA1 hash. 8. Return a success or failure depending on whether or not the hashes match. Now, I notice that the X509.X509 class has some higher level methods for getting things like the "not before" date, the "not after" date, the public key, the issuer, etc. The X509.CRL class only defines the "as_text()" method. Am I doomed to parse the CRL's as_text() output using regex? Or am I making this too hard and missing some key feature of the library? Does my algorithm sound sane? Or are there higher level certificate verification functions that I'm missing somewhere? Thank you very much for any help you can provide. -Peter