diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-04-29 11:19:52 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-05-04 14:07:15 +0200 |
commit | dbf52bb4b48748586bb6343ae4ad6d424f0631ac (patch) | |
tree | bd806636b0be51f07218f5a9db9be45af72db9ba /lib/crypto/pgp/pgp.go | |
parent | b29293d7b53c73629911ec75b2ec5954d365feed (diff) | |
download | aerc-dbf52bb4b48748586bb6343ae4ad6d424f0631ac.tar.gz |
pgp: check for signing key before signing time
Check that the signing key exists when the user issues the :sign
command. The signing key ID will be displayed in the security status
also, allowing the user to see what key will be used to sign the
message.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Jens Grassel <jens@wegtam.com>
Diffstat (limited to 'lib/crypto/pgp/pgp.go')
-rw-r--r-- | lib/crypto/pgp/pgp.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/crypto/pgp/pgp.go b/lib/crypto/pgp/pgp.go index 92a15ee6..e0c5671b 100644 --- a/lib/crypto/pgp/pgp.go +++ b/lib/crypto/pgp/pgp.go @@ -245,6 +245,24 @@ func (m *Mail) getSigner(signer string, decryptKeys openpgp.PromptFunction) (sig return signerEntity, nil } +func (m *Mail) GetSignerKeyId(s string) (string, error) { + var err error + var signerEntity *openpgp.Entity + switch strings.Contains(s, "@") { + case true: + signerEntity, err = m.getSignerEntityByEmail(s) + if err != nil { + return "", err + } + case false: + signerEntity, err = m.getSignerEntityByKeyId(s) + if err != nil { + return "", err + } + } + return signerEntity.PrimaryKey.KeyIdString(), nil +} + func handleSignatureError(e string) models.SignatureValidity { if e == "openpgp: signature made by unknown entity" { return models.UnknownEntity |