From b19b844a6326793f078b4a03eaf63ca96528796e Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Thu, 30 Dec 2021 10:25:09 +0100 Subject: pgp: PGP/MIME encryption for outgoing emails implements PGP/MIME encryption with go-pgpmail. The Encrypt() function of go-pgpmail requires a list of public keys which are taken from the keystore. The keystore is searched for the email addresses of all recipients (to, cc, and bcc). If you want to be able to read the encrypted email afterwards, add yourself as a recipient in either to, cc, or bcc as well. Public keys can be exported from gpg into aerc as follows: $ gpg --export >> ~/.local/share/aerc/keyring.asc When composing a message, the encryption is enabled with the ":encrypt" command. This sets a bool flag in the Composer struct. A reapted application of this command will toggle the flag. The encrypted message can also be signed by using the ":sign" command before or after ":encrypt". References: https://todo.sr.ht/~rjarry/aerc/6 Signed-off-by: Koni Marti --- commands/compose/encrypt.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 commands/compose/encrypt.go (limited to 'commands/compose') diff --git a/commands/compose/encrypt.go b/commands/compose/encrypt.go new file mode 100644 index 00000000..d63940b8 --- /dev/null +++ b/commands/compose/encrypt.go @@ -0,0 +1,44 @@ +package compose + +import ( + "errors" + "time" + + "git.sr.ht/~rjarry/aerc/widgets" +) + +type Encrypt struct{} + +func init() { + register(Encrypt{}) +} + +func (Encrypt) Aliases() []string { + return []string{"encrypt"} +} + +func (Encrypt) Complete(aerc *widgets.Aerc, args []string) []string { + return nil +} + +func (Encrypt) Execute(aerc *widgets.Aerc, args []string) error { + if len(args) != 1 { + return errors.New("Usage: encrypt") + } + + composer, _ := aerc.SelectedTab().(*widgets.Composer) + + composer.SetEncrypt(!composer.Encrypt()) + + var statusline string + + if composer.Encrypt() { + statusline = "Message will be encrypted." + } else { + statusline = "Message will not be encrypted." + } + + aerc.PushStatus(statusline, 10*time.Second) + + return nil +} -- cgit