aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/gpg/gpgbin
diff options
context:
space:
mode:
Diffstat (limited to 'lib/crypto/gpg/gpgbin')
-rw-r--r--lib/crypto/gpg/gpgbin/encrypt.go6
-rw-r--r--lib/crypto/gpg/gpgbin/gpgbin.go2
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/crypto/gpg/gpgbin/encrypt.go b/lib/crypto/gpg/gpgbin/encrypt.go
index 4cbac37b..e72ba148 100644
--- a/lib/crypto/gpg/gpgbin/encrypt.go
+++ b/lib/crypto/gpg/gpgbin/encrypt.go
@@ -2,6 +2,7 @@ package gpgbin
import (
"bytes"
+ "fmt"
"io"
"git.sr.ht/~rjarry/aerc/models"
@@ -27,7 +28,10 @@ func Encrypt(r io.Reader, to []string, from string) ([]byte, error) {
g.cmd.Run()
outRdr := bytes.NewReader(g.stdout.Bytes())
var md models.MessageDetails
- parse(outRdr, &md)
+ err := parse(outRdr, &md)
+ if err != nil {
+ return nil, fmt.Errorf("gpg: failure to encrypt: %v. check public key(s)", err)
+ }
var buf bytes.Buffer
io.Copy(&buf, md.Body)
diff --git a/lib/crypto/gpg/gpgbin/gpgbin.go b/lib/crypto/gpg/gpgbin/gpgbin.go
index bce30970..9f79e972 100644
--- a/lib/crypto/gpg/gpgbin/gpgbin.go
+++ b/lib/crypto/gpg/gpgbin/gpgbin.go
@@ -228,6 +228,8 @@ func parse(r io.Reader, md *models.MessageDetails) error {
md.Micalg = micalgs[micalg]
case "NODATA":
md.SignatureError = "gpg: no signature packet found"
+ case "FAILURE":
+ return fmt.Errorf(strings.TrimPrefix(line, "[GNUPG:] "))
}
}
md.Body = bytes.NewReader(msgContent)