UP | HOME

Date: [2022-09-30 Fri]

Configuring GPG for Emacs in MacOS

Table of Contents

1. pinentry fix

Decrypting with GPG failed with following message in Emacs

Error while decrypting with "/opt/homebrew/bin/gpg":

gpg: encrypted with rsa2048 key, ID 9EC749B2A876A133, created 2020-10-19 "Bibek Panthi <bpanthi977@gmail.com>" gpg: public key decryption failed: Inappropriate ioctl for device gpg: decryption failed: Inappropriate ioctl for device

in ~/.gnupg/gpg-agent.conf add the following (Source)

< Collapse code block> Expand code block
# this means clients like Emacs can get the password in their own way and push to gpg
# for this to work with Emacs, set epa-pinentry-mode to 'loopback in Emacs
allow-loopback-entry

and add to you config:

< Collapse code block> Expand code block
(setq epa-pinentry-mode 'loopback)

2. gnupg >2.4.0 doesn't work with emacs

https://www.reddit.com/r/emacs/comments/137r7j7/gnupg_241_encryption_issues_with_emacs_orgmode/

There are fixees for gnupg (and maybe emacs) being discussed here: https://dev.gnupg.org/T6481

In the meanwhile force install gnupg==2.4.0 or lower.

< Collapse code block> Expand code block
brew info gnupg | grep "From:" | cut -d " " -f 2
https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/g/gnupg.rb
< Collapse code block> Expand code block
URL=https://raw.githubusercontent.com/Homebrew/homebrew-core/59edfe598541186430d49cc34f42671e849e2fc9/Formula/gnupg.rb
wget $URL
brew uninstall --ignore-dependencies gnupg
brew install -s gnupg.rb

References


You can send your feedback, queries here