From 69d4e3895fd15f292036320d27bbe9b83651bb78 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Thu, 30 Dec 2021 10:25:08 +0100 Subject: pgp: PGP/MIME signing for outgoing emails implements PGP/MIME signing with go-pgpmail. The Sign() function of go-pgpmail requires a private (signing) key. The signing key which matches the senders email address (from field in email header) is looked up in aerc's copy of the keyring. Private keys can be exported from gpg into aerc as follows: $ gpg --export-secret-keys >> ~/.local/share/aerc/keyring.asc A message is signed with the ":sign" command. The sign command sets a bool flag in the Composer struct. Using the command repeatedly will toggle the flag. References: https://todo.sr.ht/~rjarry/aerc/6 Signed-off-by: Koni Marti --- commands/compose/sign.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 commands/compose/sign.go (limited to 'commands') diff --git a/commands/compose/sign.go b/commands/compose/sign.go new file mode 100644 index 00000000..eb985e99 --- /dev/null +++ b/commands/compose/sign.go @@ -0,0 +1,44 @@ +package compose + +import ( + "errors" + "time" + + "git.sr.ht/~rjarry/aerc/widgets" +) + +type Sign struct{} + +func init() { + register(Sign{}) +} + +func (Sign) Aliases() []string { + return []string{"sign"} +} + +func (Sign) Complete(aerc *widgets.Aerc, args []string) []string { + return nil +} + +func (Sign) Execute(aerc *widgets.Aerc, args []string) error { + if len(args) != 1 { + return errors.New("Usage: sign") + } + + composer, _ := aerc.SelectedTab().(*widgets.Composer) + + composer.SetSign(!composer.Sign()) + + var statusline string + + if composer.Sign() { + statusline = "Message will be signed." + } else { + statusline = "Message will not be signed." + } + + aerc.PushStatus(statusline, 10*time.Second) + + return nil +} -- cgit