Subject: Re: 29.1; ERC 5.5.0.29.1: Unnecessary .authinfo.gpg decryption causes connection failure to irc.libera.chat

From: "J.P." <[email-masked]>
Date: Fri, 22 Dec 2023 20:41:35 -0800

Hi Jake,

Jake <[email-masked]> writes:

> Hello
>
> I encountered an issue with authinfo interfering with ERC:
> When I attempt to connect to the irc.libera.chat server with a random
> nickname and no password, if a ~/.authinfo.gpg file is present on my
> system (or any .gpg file in the auth-sources variable), ERC attempts to
> decrypt this file when connecting. When I don't decrypt it, the
> connection fails.
>
> This occurs with emacs -Q.
>
> If I set auth-sources to nil, or change the name of the .gpg file to
> something else not in auth-sources, I get the expected behavior; i.e., it connects to the server.
>
> Steps to reproduce:
> 1. have an encrypted ~/.authinfo.gpg file (this will also be an element of
> the variable auth-sources, which is the default) 
> 2. emacs -Q
> 3. M-x erc-tls
> interactively: RET on default values irc.libera.chat and 6697, then enter a unique nickname and do not
> enter a password
> 4. be prompted to decrypt ~/.authinfo.gpg

I haven't tried very hard to reproduce this yet, but I can't seem to get
Emacs to prompt me from emacs -Q. It just decrypts the file straight
away if it has access to the key it was encrypted with and fails
otherwise. So, I was wondering if this prompt is coming from somewhere
external, such as a secrets manager or a TTY pinentry program, for
example,

  Please enter the passphrase to unlock the OpenPGP secret key:
  "Your Name <[email-masked]>"
  3071 RSA key, ID DEAD..BEEF
  created 2023-12-22 17:30 (main key ID ...).
  
  Passprhase: ____________________________

  <OK> <Cancel>

(although, from your description, it seems like you're using graphical
Emacs). Also, is the "irc.libera.chat:6697" buffer completely blank
after the failure? And is there anything relevant recorded in the
"*Messages*" buffer? Perhaps something like:

  For information about GNU Emacs and the GNU system, type C-h C-a.
  Decrypting /root/.authinfo.gpg...done
  epa-file-insert-file-contents:
  Opening input file: Decryption failed, , No secret key

I'm mainly trying to avoid having to replicate your setup in a VM.

TIA,
J.P.