diff options
author | Koni Marti <koni.marti@gmail.com> | 2021-12-30 10:25:09 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-01-07 13:45:34 +0100 |
commit | b19b844a6326793f078b4a03eaf63ca96528796e (patch) | |
tree | 06fdd642c321347d0b30a5ce4def17851fbd18bf /lib | |
parent | 69d4e3895fd15f292036320d27bbe9b83651bb78 (diff) | |
download | aerc-b19b844a6326793f078b4a03eaf63ca96528796e.tar.gz |
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 <koni.marti@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/keystore.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/keystore.go b/lib/keystore.go index c211067..0b9d41a 100644 --- a/lib/keystore.go +++ b/lib/keystore.go @@ -53,6 +53,16 @@ func UnlockKeyring() { os.Remove(lockpath) } +func GetEntityByEmail(email string) (e *openpgp.Entity, err error) { + for _, entity := range Keyring { + ident := entity.PrimaryIdentity() + if ident != nil && ident.UserId.Email == email { + return entity, nil + } + } + return nil, fmt.Errorf("entity not found in keyring") +} + func GetSignerEntityByEmail(email string) (e *openpgp.Entity, err error) { for _, key := range Keyring.DecryptionKeys() { if key.Entity == nil { |