aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartkk <bartkk@bartkk.xyz>2024-04-03 08:35:49 +0200
committerRobin Jarry <robin@jarry.cc>2024-04-03 11:16:53 +0200
commit4cbd116f034813216955540567f333f237de1bbe (patch)
tree1953750557b8438b86e622acb6f047f734fd260a
parent28fde6118fca2b1f93457d493572a4401e8448ac (diff)
downloadaerc-4cbd116f034813216955540567f333f237de1bbe.tar.gz
aerc-4cbd116f034813216955540567f333f237de1bbe.zip
gpg: add pgp-self-encrypt option
Add an option to encrypt outgoing messages to the sender or the key specified in pgp-key-id. Implements: https://todo.sr.ht/~rjarry/aerc/237 Changelog-added: New `pgp-self-encrypt` option in `accounts.conf`. Signed-off-by: Bartkk <bartkk@bartkk.xyz> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--app/compose.go9
-rw-r--r--config/accounts.go1
-rw-r--r--doc/aerc-accounts.5.scd6
3 files changed, 16 insertions, 0 deletions
diff --git a/app/compose.go b/app/compose.go
index 6cdc3458..469f3c36 100644
--- a/app/compose.go
+++ b/app/compose.go
@@ -947,6 +947,15 @@ func (c *Composer) WriteMessage(header *mail.Header, writer io.Writer) error {
if err != nil {
return err
}
+
+ if c.acct.acct.PgpSelfEncrypt {
+ signer, err := c.Signer()
+ if err != nil {
+ return err
+ }
+ rcpts = append(rcpts, signer)
+ }
+
cleartext, err = CryptoProvider().Encrypt(&buf, rcpts, signer, DecryptKeys, header)
if err != nil {
return err
diff --git a/config/accounts.go b/config/accounts.go
index b5bfbe9a..6e0d6268 100644
--- a/config/accounts.go
+++ b/config/accounts.go
@@ -107,6 +107,7 @@ type AccountConfig struct {
PgpAttachKey bool `ini:"pgp-attach-key"`
PgpOpportunisticEncrypt bool `ini:"pgp-opportunistic-encrypt"`
PgpErrorLevel int `ini:"pgp-error-level" parse:"ParsePgpErrorLevel" default:"warn"`
+ PgpSelfEncrypt bool `ini:"pgp-self-encrypt"`
// AuthRes
TrustedAuthRes []string `ini:"trusted-authres" delim:","`
diff --git a/doc/aerc-accounts.5.scd b/doc/aerc-accounts.5.scd
index 20c88b36..d735e45c 100644
--- a/doc/aerc-accounts.5.scd
+++ b/doc/aerc-accounts.5.scd
@@ -189,6 +189,12 @@ Note that many of these configuration options are written for you, such as
Default: _false_
+*pgp-self-encrypt* = _true_|_false_
+ If _true_, any outgoing encrypted email will be also encrypted for the sender
+ or the key specified in *pgp-key-id*.
+
+ Default: _false_
+
*pgp-error-level* = _none_|_warn_|_error_
The level of error to display when opportunistic encryption cannot be
performed. See *pgp-opportunistic-encryption*.