Subject: bug#20465: 24.4; GnuTLS integration seems faulty

From: Leandro Facchinetti <[email-masked]>
Date: Wed, 29 Apr 2015 15:34:56 -0400

I'm trying to retrieve a URL hosted on CloudFlare with Universal SSL
enabled (more about what's that here:
https://blog.cloudflare.com/introducing-universal-ssl/).

The following command is the one causing the issue:

    (url-retrieve-synchronously "https://kill-the-newsletter.com")

As you can see on the "Recent messages" section of this bug report, I'm
getting back a -12 error, which by the GnuTLS manual means
"GNUTLS_E_FATAL_ALERT_RECEIVED: A TLS fatal alert has been received."

But then I tried connecting with the server using the `gnutls-cli' tool
provided by GnuTLS itself. From the command line, I ran:

    $ gnutls-cli kill-the-newsletter.com

And it worked.

This leads me to conclude that somehow `gnutls.c' in Emacs is calling
the library in a way it shouldn't.

I'd love to help fix this myself, but I'm not experienced with C
programming outside the assignments I did as an undergrad a few years
ago, and I don't understand the internals of Emacs and GnuTLS very well.

So I ask you to please guide me on the right direction.

Thanks!

In GNU Emacs 24.4.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.2)
 of 2015-04-17 on andyrtr
Windowing system distributor `The X.Org Foundation', version 11.0.11701000
Configured using:
 `configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 --param=ssp-buffer-size=4' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'

Important settings:
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<help-echo> M-: C-g M-: ( C-y SPC " h t t p s : / / 
k i l l - t h e - n e w s l e t t e r . c o m " ) <return> 
q M-: <up> C-S-e M-w C-g M-x e m a s <backspace> c 
s - r e p o <tab> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> r e p o <tab> r t <tab> <r
eturn>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Quit
Contacting host: kill-the-newsletter.com:443
gnutls.c: [0] (Emacs) fatal error: A TLS fatal alert has been received.
gnutls.c: [0] (Emacs) Received alert:  Internal error
gnutls.el: (err=[-12] A TLS fatal alert has been received.) boot: (:priority NORMAL :hostname kill-the-newsletter.com :loglevel 0 :min-prime-bits 256 :trustfiles (/etc/ssl/certs/ca-certificates.crt) :crlfiles nil :keylist nil :verify-flags nil :verify-error nil :callbacks nil)
Entering debugger...
Back to top level.
Quit
Making completion list...

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message format-spec rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader sendmail
mail-utils help-mode easymenu debug gnutls cl-loaddefs cl-lib
network-stream starttls url-http tls mail-parse rfc2231 rfc2047 rfc2045
ietf-drums url-gw url-cache url-auth url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
url-parse auth-source eieio byte-opt bytecomp byte-compile cconv
eieio-core gnus-util mm-util help-fns mail-prsvr password-cache url-vars
mailcap time-date tooltip electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 91117 5130)
 (symbols 48 19938 0)
 (miscs 40 45 118)
 (strings 32 18371 4972)
 (string-bytes 1 493143)
 (vectors 16 11427)
 (vector-slots 8 411227 6068)
 (floats 8 74 213)
 (intervals 56 245 1)
 (buffers 960 13)
 (heap 1024 38752 1009))

-- 
Leandro Facchinetti <[email-masked]>
https://www.leafac.com
GPG key: 3DF3D583