]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Add.
authorSimon Josefsson <simon@josefsson.org>
Wed, 27 Dec 2006 08:23:10 +0000 (08:23 +0000)
committerSimon Josefsson <simon@josefsson.org>
Wed, 27 Dec 2006 08:23:10 +0000 (08:23 +0000)
NEWS
THANKS
tests/Makefile.am
tests/certificate_set_x509_crl.c [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index aa8022ed5cf12ae18b4ef12830afd5abd7ea646d..fe46cc0aa1d299020bd7b9092978a59e3f2b39d4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,10 @@ See the end for copying conditions.
 
 * Version 1.7.1 (unreleased)
 
+** Fix gnutls_certificate_set_x509_crl.
+Also added a self-test in tests/certificate_set_x509_crl.c to test the
+function.  Reported by Max Kellermann <max@duempel.org>.
+
 ** Bootstrap tools changed.
 We now require autoconf 2.61, automake 1.10, and gettext 0.16, when
 building GnuTLS from CVS.  Libtool 1.5.22 is used.
diff --git a/THANKS b/THANKS
index ecdf0ecae416e44da46cfadd79607094888a0289..6245c5b8ff6654efd84452aae6983c46b2ff0c9a 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -62,6 +62,7 @@ Roman Bogorodskiy               <novel@FreeBSD.org>
 Robert Millan                   <rmillan@ackstorm.es>
 Kataja Kai                      <kai.kataja@op.fi>
 Georg Schwarz                   <georg.schwarz@freenet.de>
+Max Kellermann                  <max@duempel.org>
 
 ----------------------------------------------------------------------
 Copying and distribution of this file, with or without modification,
index e77890731823e6265e92308478b17ba1a274498b..c61fe6abe6043bf46b12e0bc5c7f6f24fb45b9e0 100644 (file)
@@ -30,7 +30,7 @@ LDADD = ../lib/libgnutls.la ../gl/libgnu.la ../lgl/liblgnu.la libutils.la
 noinst_LTLIBRARIES = libutils.la
 libutils_la_SOURCES = utils.h utils.c
 
-ctests = simple openssl gc set_pkcs12_cred certder
+ctests = simple openssl gc set_pkcs12_cred certder certificate_set_x509_crl
 openssl_LDADD = $(LDADD) ../libextra/libgnutls-openssl.la
 if HAVE_FORK
 ctests +=  anonself pskself dhepskself tlsia resume
diff --git a/tests/certificate_set_x509_crl.c b/tests/certificate_set_x509_crl.c
new file mode 100644 (file)
index 0000000..ddc8088
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2006  Free Software Foundation, Inc.
+ *
+ * Author: Simon Josefsson
+ *
+ * This file is part of GNUTLS.
+ *
+ * The GNUTLS library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gnutls/gnutls.h>
+#include <gnutls/x509.h>
+
+static char crl[] =
+  "-----BEGIN X509 CRL-----\n"
+  "MIIB9DCCAV8CAQEwCwYJKoZIhvcNAQEFMIIBCDEXMBUGA1UEChMOVmVyaVNpZ24s\n"
+  "IEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdvcmsxRjBEBgNVBAsT\n"
+  "PXd3dy52ZXJpc2lnbi5jb20vcmVwb3NpdG9yeS9SUEEgSW5jb3JwLiBieSBSZWYu\n"
+  "LExJQUIuTFREKGMpOTgxHjAcBgNVBAsTFVBlcnNvbmEgTm90IFZhbGlkYXRlZDEm\n"
+  "MCQGA1UECxMdRGlnaXRhbCBJRCBDbGFzcyAxIC0gTmV0c2NhcGUxGDAWBgNVBAMU\n"
+  "D1NpbW9uIEpvc2Vmc3NvbjEiMCAGCSqGSIb3DQEJARYTc2ltb25Aam9zZWZzc29u\n"
+  "Lm9yZxcNMDYxMjI3MDgwMjM0WhcNMDcwMjA3MDgwMjM1WjAjMCECEC4QNwPfRoWd\n"
+  "elUNpllhhTgXDTA2MTIyNzA4MDIzNFowCwYJKoZIhvcNAQEFA4GBAD0zX+J2hkcc\n"
+  "Nbrq1Dn5IKL8nXLgPGcHv1I/le1MNo9t1ohGQxB5HnFUkRPAY82fR6Epor4aHgVy\n"
+  "b+5y+neKN9Kn2mPF4iiun+a4o26CjJ0pArojCL1p8T0yyi9Xxvyc/ezaZ98HiIyP\n"
+  "c3DGMNR+oUmSjKZ0jIhAYmeLxaPHfQwR\n"
+  "-----END X509 CRL-----\n";
+
+/* Test regression of bug reported by Max Kellermann <max@duempel.org>
+   in Message-ID: <20061211075202.GA1517@roonstrasse.net> to the
+   gnutls-dev@gnupg.org list. */
+
+int
+main (void)
+{
+  int rc;
+  gnutls_certificate_credentials_t crt;
+  gnutls_datum_t crldatum = { crl, strlen (crl) };
+  gnutls_x509_crl_t crl;
+
+  rc = gnutls_global_init ();
+  if (rc)
+    {
+      printf ("gnutls_global_init rc %d: %s\n", rc, gnutls_strerror (rc));
+      return 1;
+    }
+
+  rc = gnutls_certificate_allocate_credentials (&crt);
+  if (rc)
+    {
+      printf ("gnutls_certificate_allocate_credentials rc %d: %s\n",
+             rc, gnutls_strerror (rc));
+      return 1;
+    }
+
+  rc = gnutls_certificate_set_x509_crl_mem (crt, &crldatum,
+                                           GNUTLS_X509_FMT_PEM);
+  if (rc != 1)
+    {
+      printf ("gnutls_certificate_set_x509_crl_mem num %d\n", rc);
+      return 1;
+    }
+
+  rc = gnutls_x509_crl_init (&crl);
+  if (rc)
+    {
+      printf ("gnutls_x509_crl_init rc %d: %s\n", rc, gnutls_strerror (rc));
+      return 1;
+    }
+
+  rc = gnutls_x509_crl_import (crl, &crldatum, GNUTLS_X509_FMT_PEM);
+  if (rc)
+    {
+      printf ("gnutls_x509_crl_import rc %d: %s\n", rc, gnutls_strerror (rc));
+      return 1;
+    }
+
+  rc = gnutls_certificate_set_x509_crl (crt, &crl, 1);
+  if (rc)
+    {
+      printf ("gnutls_certificate_set_x509_crl rc %d: %s\n",
+             rc, gnutls_strerror (rc));
+      return 1;
+    }
+
+  gnutls_x509_crl_deinit (crl);
+
+  gnutls_certificate_free_credentials (crt);
+
+  gnutls_global_deinit ();
+
+  return 0;
+}