From fad1fc8f1b57b819a774c171b933b0866804044a Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 21 Sep 2018 14:06:15 -0400 Subject: [PATCH] Resolve GPG keys by user name instead of address #877 epa-file-encrypt-to is now set to the ids of all keys that match user-full-name, if it is set. This should fix issues with multiple keys with the same email addresses. --- modules/config/default/config.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/config/default/config.el b/modules/config/default/config.el index 37b55265e..699581137 100644 --- a/modules/config/default/config.el +++ b/modules/config/default/config.el @@ -20,7 +20,13 @@ "~/.authinfo.gpg")) (after! epa - (setq epa-file-encrypt-to (or epa-file-encrypt-to user-mail-address) + (setq epa-file-encrypt-to + (or epa-file-encrypt-to + ;; Collect all public key IDs with your username + (unless (string-empty-p user-full-name) + (cl-loop for key in (epg-list-keys (epg-make-context) user-full-name) + collect (epg-sub-key-id (car (epg-key-sub-key-list key))))) + user-mail-address) ;; With GPG 2.1, this forces gpg-agent to use the Emacs minibuffer to ;; prompt for the key passphrase. epa-pinentry-mode 'loopback))