Subject: bug#10904: 24.0.93; Infinite loop in GnuTLS code during Gnus nnimap-initiated SSL handshake

From: Ted Zlatanov <[email-masked]>
Date: Fri, 30 Mar 2012 08:13:44 -0400

On Sat, 24 Mar 2012 18:04:33 -0400 Thomas Fitzsimmons <[email-masked]> wrote: 

TF> Lars Magne Ingebrigtsen <[email-masked]> writes:
>> Thomas Fitzsimmons <[email-masked]> writes:
>>> 2) If gnutls.el fails to handshake with a server then Emacs enters an
>>> infinite loop retrying the handshake
>> 
>> That sounds like a bug on our part.  Do you know whether there's any way
>> to reproduce this bug without having access to a server that has the
>> particular problems you've encountered?  For instance, a setting that
>> makes gnutls try the wrong ciphers or something.  Then I could try to
>> reproduce and chase down the infloop bug on the Emacs side.

TF> Yes, this replicates it on my setup:

TF> $ gnutls-serv --http

TF> $ emacs -Q

TF> Eval:

TF> (setq gnutls-log-level 5
TF>       message-log-max t
TF>       gnus-directory "~/.emacs.d/gnus/News/"
TF>       gnus-startup-file "~/.emacs.d/gnus/.newsrc"
TF>       gnus-secondary-select-methods
TF>       (quote ((nnimap "localhost"
TF>                       (nnimap-server-address "localhost")
TF>                       (nnimap-server-port 5556)
TF>                       (nnimap-user "fitzsim")))))

TF> M-x gnus

The `gnutls-serv' call has nothing to do with Gnus, right?

I started it with -p 5556 and then

(open-gnutls-stream "tls" "tls-buffer" "localhost" 5556)

prints the following in *Messages*:

gnutls.c: [0] (Emacs) fatal error: A TLS fatal alert has been received.
gnutls.c: [0] (Emacs) Received alert:  Handshake failed
gnutls.el: (err=[-12] A TLS fatal alert has been received.) boot: (:priority NORMAL :hostname localhost :loglevel 0 :min-prime-bits nil :trustfiles (/etc/ssl/certs/ca-certificates.crt) :crlfiles nil :keylist nil :verify-flags nil :verify-error nil :verify-hostname-error nil :callbacks nil)
Entering debugger...
gnutls.c: [0] (Emacs) fatal error: The specified session has been invalidated for some reason.

So there's no infinite loop with the default settings to a `gnutls-serv'
instance, and I'm sure we would have heard about such a lockup from
other users if it was happening.  It seems to be specific to your IMAP
server only.  I'm not sure how to replicate the bug, unfortunately.  Is
setting up a tunnel to your server out of the question?

Ted