After a few Goging I found some common answers to this question, such as:
some code:
X509 = decoded_signature X509.load_cert_string (certificate) pubkey = x509.get_pubkey () pubkey.reset_context (MD = SHA1) pubkey.verify_init () pubkey.verify_update (content) = Signaturekdecode ( "base 64") If pubkey.verify_final (decoded_signature) == 0: print "error 'sys.exit (1)
and put the above code M2Crypto work properly 0.20 Does. But I really need to even think that using the same M2Crypto 0.16 (government package in RHEL5), and I've since using pubkey.verify_final method in this special edition issues signing parameter does not exist. So how can I do this? Thanks to M2Crypto 0.16
Lucky OpenSSL function that you are in need M2Crypto 0.16, it is just Python method Which is not providing you additional logic that you need. It's easy to work around where you will say pubkey.verify_final (decoded_signature)
, call pubkey_verify_final (pubkey, decoded_signature)
, which will define in your code as you:
M2Crypto imports m2 def pubkey_verify_final (pubkey, decoded_signature) to return m2.verify_final (pubkey.ctx, decoded_signature, pubkey.pkey)
( Note, I did not actually test that, compared to the source between 0.16 and 0.20 only.)
Comments
Post a Comment