all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: michael.albinus@gmx.de, Ted Zlatanov <tzz@lifelogs.com>
Cc: emacs-devel@gnu.org
Subject: Re: NSM certificate prompt
Date: Sat, 13 Dec 2014 21:13:50 +0200	[thread overview]
Message-ID: <83vblf4b2p.fsf@gnu.org> (raw)
In-Reply-To: <83y4qb4eeg.fsf@gnu.org>

> Date: Sat, 13 Dec 2014 20:01:59 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> GnuTLS on Windows uses the CertEnumCertificatesInStore API to retrieve
> all the Root and Certification Authority certificates known to the
> system.  I suppose at least IE uses the same API, so I wonder how come
> GnuTLS fails to validate the certificates, while IE succeeds.
> 
> I guess some debugging is in order.

Ha!  It's very simple: we don't call the GnuTLS function that adds
system's default trusted CAs to the data used for certificate
verification.  The simple patch below solves the problem for me.

Any objections to installing this?  Including on the branch?  Ted?

What about Posix systems -- won't calling
gnutls_certificate_set_x509_system_trust remove the need to load
gnutls-trustfiles explicitly for every TLS connection?

diff --git a/src/gnutls.c b/src/gnutls.c
index ad4d997..bbe5d49 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -103,6 +103,11 @@ enum extra_peer_verification
 DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_key_file,
 	       (gnutls_certificate_credentials_t, const char *, const char *,
 		gnutls_x509_crt_fmt_t));
+#if GNUTLS_VERSION_MAJOR +					\
+  (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20) > 3
+DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_system_trust,
+	       (gnutls_certificate_credentials_t));
+#endif
 DEF_GNUTLS_FN (int, gnutls_certificate_set_x509_trust_file,
 	       (gnutls_certificate_credentials_t, const char *,
 		gnutls_x509_crt_fmt_t));
@@ -227,6 +232,10 @@ enum extra_peer_verification
   LOAD_GNUTLS_FN (library, gnutls_certificate_set_verify_flags);
   LOAD_GNUTLS_FN (library, gnutls_certificate_set_x509_crl_file);
   LOAD_GNUTLS_FN (library, gnutls_certificate_set_x509_key_file);
+#if GNUTLS_VERSION_MAJOR +					\
+  (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20) > 3
+  LOAD_GNUTLS_FN (library, gnutls_certificate_set_x509_system_trust);
+#endif
   LOAD_GNUTLS_FN (library, gnutls_certificate_set_x509_trust_file);
   LOAD_GNUTLS_FN (library, gnutls_certificate_type_get);
   LOAD_GNUTLS_FN (library, gnutls_certificate_verify_peers2);
@@ -314,6 +323,10 @@ enum extra_peer_verification
 #define fn_gnutls_certificate_set_verify_flags	gnutls_certificate_set_verify_flags
 #define fn_gnutls_certificate_set_x509_crl_file	gnutls_certificate_set_x509_crl_file
 #define fn_gnutls_certificate_set_x509_key_file gnutls_certificate_set_x509_key_file
+#if GNUTLS_VERSION_MAJOR +					\
+  (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20) > 3
+#define fn_gnutls_certificate_set_x509_system_trust gnutls_certificate_set_x509_system_trust
+#endif
 #define fn_gnutls_certificate_set_x509_trust_file gnutls_certificate_set_x509_trust_file
 #define fn_gnutls_certificate_type_get		gnutls_certificate_type_get
 #define fn_gnutls_certificate_verify_peers2	gnutls_certificate_verify_peers2
@@ -1308,6 +1321,14 @@ one trustfile (usually a CA bundle).  */)
       int file_format = GNUTLS_X509_FMT_PEM;
       Lisp_Object tail;
 
+#if GNUTLS_VERSION_MAJOR +					\
+  (GNUTLS_VERSION_MINOR > 0 || GNUTLS_VERSION_PATCH >= 20) > 3
+      ret = fn_gnutls_certificate_set_x509_system_trust (x509_cred);
+      if (ret < GNUTLS_E_SUCCESS)
+	GNUTLS_LOG2i (4, max_log_level, "setting system trust failed with code ",
+		      ret);
+#endif
+
       for (tail = trustfiles; CONSP (tail); tail = XCDR (tail))
 	{
 	  Lisp_Object trustfile = XCAR (tail);



  parent reply	other threads:[~2014-12-13 19:13 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-13 14:43 NSM certificate prompt Eli Zaretskii
2014-12-13 15:12 ` Lars Magne Ingebrigtsen
2014-12-13 16:01   ` Eli Zaretskii
2014-12-13 16:04     ` Lars Magne Ingebrigtsen
2014-12-13 16:46       ` Eli Zaretskii
2014-12-13 17:27         ` Lars Magne Ingebrigtsen
2014-12-13 15:27 ` Michael Albinus
2014-12-13 15:35   ` Lars Magne Ingebrigtsen
2014-12-13 16:57     ` Michael Albinus
2014-12-13 17:06       ` Eli Zaretskii
2014-12-13 17:29       ` Lars Magne Ingebrigtsen
2014-12-13 18:03         ` Eli Zaretskii
2014-12-13 18:06           ` Lars Magne Ingebrigtsen
2014-12-13 19:16             ` Michael Albinus
2014-12-13 20:02               ` Ted Zlatanov
2014-12-13 16:03   ` Eli Zaretskii
2014-12-13 16:39   ` Eli Zaretskii
2014-12-13 17:06     ` Michael Albinus
2014-12-13 18:01       ` Eli Zaretskii
2014-12-13 19:09         ` Michael Albinus
2014-12-13 19:13         ` Eli Zaretskii [this message]
2014-12-13 19:47           ` Ted Zlatanov
2014-12-13 20:06             ` Eli Zaretskii
2014-12-14  0:23               ` Lars Magne Ingebrigtsen
2014-12-14  1:38               ` Ted Zlatanov
2014-12-14  3:46                 ` Eli Zaretskii
2014-12-14  8:16                   ` Lars Magne Ingebrigtsen
2014-12-14 16:04                     ` Eli Zaretskii
2014-12-19 12:14                       ` Lars Ingebrigtsen
2014-12-19 14:41                         ` Eli Zaretskii
2014-12-19 16:42                           ` Ivan Shmakov
2014-12-19 16:47                           ` Lars Ingebrigtsen
2014-12-19 19:53                         ` Simon Leinen
2014-12-19 21:37                           ` Eli Zaretskii
2014-12-14 11:34                   ` Ted Zlatanov
2014-12-14 12:52                     ` Michael Albinus
2014-12-14 16:53                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83vblf4b2p.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=tzz@lifelogs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.