How to recreate the following signing cmd-line OpenSSL call using M2Crypto in Python?
问题 This works perfectly in command-line, I would like to do the same using M2Crypto in Python code. openssl smime -binary -sign -signer certificate.pem -inkey key.pem \ -in some_file.txt -out signed_file -outform DER \ -passin pass:somepassword 回答1: This is how I have been using M2Crypto to sign a file. text = open('/path/to/some_file.txt').read() passphrase = 'somepassword' buffer = M2Crypto.BIO.MemoryBuffer(text) signer = M2Crypto.SMIME.SMIME() signer.load_key('/path/to/key.pem', '/path/to