From dbf52bb4b48748586bb6343ae4ad6d424f0631ac Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Fri, 29 Apr 2022 11:19:52 -0500 Subject: 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 Tested-by: Jens Grassel --- lib/crypto/gpg/gpg.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/crypto/gpg/gpg.go') diff --git a/lib/crypto/gpg/gpg.go b/lib/crypto/gpg/gpg.go index 66cd3725..457788dc 100644 --- a/lib/crypto/gpg/gpg.go +++ b/lib/crypto/gpg/gpg.go @@ -51,6 +51,10 @@ func (m *Mail) Sign(buf *bytes.Buffer, signer string, decryptKeys openpgp.Prompt func (m *Mail) Close() {} +func (m *Mail) GetSignerKeyId(s string) (string, error) { + return gpgbin.GetPrivateKeyId(s) +} + func handleSignatureError(e string) models.SignatureValidity { if e == "gpg: missing public key" { return models.UnknownEntity -- cgit