How to digitally sign a message with M2Crypto using the keys within a DER format certificate
Posted
by Pablo Santos
on Stack Overflow
See other posts from Stack Overflow
or by Pablo Santos
Published on 2010-03-08T13:00:56Z
Indexed on
2010/03/08
23:51 UTC
Read the original article
Hit count: 602
Hi everyone.
I am working on a project to implement digital signatures of outgoing messages and decided to use M2Crypto for that.
I have a certificate (in DER format) from which I extract the keys to sign the message. For some reason I keep getting an ugly segmentation fault error when I call the "sign_update" method.
Given the previous examples I have read here, I am clearly missing something.
Here is the example I am working on:
from M2Crypto.X509 import *
cert = load_cert( 'certificate.cer', format=0 )
Pub_key = cert.get_pubkey()
Pub_key.reset_context(md='sha1')
Pub_key.sign_init()
Pub_key.sign_update( "This should be good." )
print Pub_key.sign_final()
Thanks in advance for the help,
Pablo
© Stack Overflow or respective owner