Migrated from: https://gitlab.com/m2crypto/m2crypto/-/issues/164
Created by: Matheus Bratfisch (@matheusbrat)
Created at: 2017-03-08T06:12:11.023Z
Closed at: 2023-02-03T15:44:48.955Z
Milestone: 0.41
cleartext = 'hello from earth'
buf = BIO.MemoryBuffer(cleartext)
s = SMIME.SMIME()
s.load_key('helpers/testkey/signer_key.pem', 'helpers/testkey/signer.pem')
p7 = s.sign(buf)
out = BIO.MemoryBuffer()
p7.write(out)
buf = out.read()
buf = buf.strip()
s.write(out, p7, BIO.MemoryBuffer(cleartext))
print out.read()
If you run something like this you will get this output
$ python sign.py
MIME-Version: 1.0
Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="sha-256"; boundary="----AD31D973F4DB81328850B09603E8D0DD"
This is an S/MIME signed message
------AD31D973F4DB81328850B09603E8D0DD
hello from earth
Which is not the correct/complete body of the smime sign. To get the full signed message I had to add SMIME.PKCS7_DETACHED
to the sign method so it will be like this:
s.sign(buf, SMIME.PKCS7_DETACHED)
The document howto.smime.html
has the correct example for signing
, which works perfectly, but on the Here's how to generate an S/MIME-signed/encrypted message:
https://gitlab.com/m2crypto/m2crypto/blob/master/doc/howto.smime.html#L979 it calls .sign
without the parameter so the message generated doesn't contain the correct message.
Also on the example for decrypt and verify https://gitlab.com/m2crypto/m2crypto/blob/master/doc/howto.smime.html#L1122
I think it should be v = s.verify(p7, data)
Also, is there a use case where the user doesn't want to pass a data
for the verify command? Is there a use call to call sign without the second parameter?
Sorry if I'm miss understanding something, I'm very new to M2Crypto.
Thanks.
Changed on 2017-03-08T06:12:37.910Z by Matheus Bratfisch:
mentioned in issue #108
Changed on 2017-10-05T23:21:19.515Z by Matěj Cepl:
changed milestone to 0.29
Changed on 2018-02-23T21:10:28.227Z by Matěj Cepl:
removed milestone
Changed on 2023-02-03T10:40:55.894Z by Matěj Cepl:
marked #108 as a duplicate of this issue
(Last edited at 2023-02-03T10:40:55.895Z.)
Changed on 2023-02-03T10:40:56.213Z by Matěj Cepl:
marked this issue as related to #108
(Last edited at 2023-02-03T10:40:56.215Z.)
Changed on 2023-02-03T15:44:48.807Z by Matěj Cepl:
marked this issue as a duplicate of #223
(Last edited at 2023-02-03T15:44:48.810Z.)
Changed on 2023-02-03T15:44:49.196Z by Matěj Cepl:
marked this issue as related to #223
(Last edited at 2023-02-03T15:44:49.199Z.)