diff options
author | Koni Marti <koni.marti@gmail.com> | 2024-08-06 22:37:29 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-10-12 00:12:29 +0200 |
commit | 4b25d04509371664883e344aaa9fbf2f403529f3 (patch) | |
tree | bfcf17a16c01c924b53cd93a8c91bb63a113d18b /lib/crypto/gpg/writer.go | |
parent | 163ea3ec7d2af3bac1afe6489071a8a286f282b8 (diff) | |
download | aerc-4b25d04509371664883e344aaa9fbf2f403529f3.tar.gz |
crypto: add pinentry support to gpg
Add pinentry support to GPG for signing, enrypting and decrypting
messages.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/crypto/gpg/writer.go')
-rw-r--r-- | lib/crypto/gpg/writer.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/crypto/gpg/writer.go b/lib/crypto/gpg/writer.go index c879bc7f..9c12c6bb 100644 --- a/lib/crypto/gpg/writer.go +++ b/lib/crypto/gpg/writer.go @@ -11,6 +11,7 @@ import ( "net/mail" "git.sr.ht/~rjarry/aerc/lib/crypto/gpg/gpgbin" + "git.sr.ht/~rjarry/aerc/lib/pinentry" "github.com/emersion/go-message" "github.com/emersion/go-message/textproto" ) @@ -27,6 +28,9 @@ func (es *EncrypterSigner) Write(p []byte) (int, error) { } func (es *EncrypterSigner) Close() (err error) { + pinentry.Enable() + defer pinentry.Disable() + r := bytes.NewReader(es.msgBuf.Bytes()) enc, err := gpgbin.Encrypt(r, es.to, es.from) if err != nil { @@ -72,6 +76,9 @@ func (s *Signer) Close() (err error) { _ = textproto.WriteHeader(&buf, header.Header) _, _ = io.Copy(&buf, msg.Body) + pinentry.Enable() + defer pinentry.Disable() + sig, micalg, err := gpgbin.Sign(bytes.NewReader(buf.Bytes()), s.from) if err != nil { return err |