emersion/go-pgpmail

Provide example usage of signing email

vdot0x23 opened this issue · 4 comments

@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 :)

badsig.txt

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.

@grmat, I'm also still losing hair over this one :)

How did you determine that the signature matches an empty string (would be useful for debugging)?

Fixed Sign in 24b3549 and 1c65489, added an example in 8f265f6.