Subject: 25.0.50; gnutls-negotiate error "Invalid format operation %u"
From: lo2net <[email-masked]>
To: [email-masked]
Date: Sat, 27 Jun 2015 11:55:43 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi all,
I've got a problem: when using (gnutls-negotiate :verify-error t) to initialize a SSL/TLS
connection , server has an expired certificate cause gnutls-boot signal
an error "Invalid format operation %u", apparently it's not related to
gnutls-error. So digging into the source
code, here is the error signal:

src/gnutls.c:1511

      if (verify_error_all
          || !NILP (Fmember (QCgnutls_bootprop_trustfiles, verify_error)))
        {
	  emacs_gnutls_deinit (proc);
	  error ("Certificate validation failed %s, verification code %u",
		 c_hostname, peer_verification);
        }

After checking elisp manual and source code, function Fformat(error call
it to format string) does not
support '%u', here should using '%d' instead.

I made a simple patch for this:
From d046b24f7cee1b30e45dd094c0299304cfd7c270 Mon Sep 17 00:00:00 2001
From: lo2net <[email-masked]>
Date: Thu, 25 Jun 2015 17:00:03 +0800
Subject: [PATCH] gnutls-boot: fix error "Invalid format operation %u" when
 certificate validation fail

---
 src/gnutls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gnutls.c b/src/gnutls.c
index cab2404..6a2c873 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -1512,7 +1512,7 @@ one trustfile (usually a CA bundle).  */)
           || !NILP (Fmember (QCgnutls_bootprop_trustfiles, verify_error)))
         {
 	  emacs_gnutls_deinit (proc);
-	  error ("Certificate validation failed %s, verification code %u",
+	  error ("Certificate validation failed %s, verification code %d",
 		 c_hostname, peer_verification);
         }
       else
-- 
1.9.5.msysgit.1