Provide example usage of signing email
vdot0x23 opened this issue · 4 comments
vdot0x23 commented
@jbjjbjjbj and I tried the snippet below and Evolution said the resulting signature was BAD (i.e. the signature did not match the message.
var h textproto.Header
h.Add("From", n.sender)
h.Add("To", recipient)
h.Add("Subject", subject)
var hEmpty textproto.Header
wcSigned, err := pgpmail.Sign(wc, h, hEmpty, n.secretSigningKey, nil)
if err != nil {
return err
}
_, err = fmt.Fprintf(wcSigned, body)
if err != nil {
return err
}
err = wcSigned.Close()
if err != nil {
return err
}
Resulting email is attached (renamed from .eml
to .txt
), please let me know if you need more information, thank you :)
emersion commented
The GoDoc page has some examples. see e.g. https://godoc.org/github.com/emersion/go-pgpmail#example-Encrypt
grmat commented
It's not obvious to use for me either. Using Sign()
similarly to Encrypt()
results in header weirdness and the signature will match an empty string, not the written content.