[SCM] GNU gnutls branch, gnutls_3_0_x-2, updated. gnutls_3_0_19-27-g853484a

"Nikos Mavrogiannopoulos" <[email protected]>
Newsgroups gmane.comp.encryption.gpg.gnutls.cvs
Message-ID <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU gnutls".

http://git.savannah.gnu.org/cgit/gnutls.git/commit/?id=853484a8d2142771ad1484b5a39c58966b63f136

The branch, gnutls_3_0_x-2 has been updated
       via  853484a8d2142771ad1484b5a39c58966b63f136 (commit)
       via  de02e234ae93e1ec9f5716328c8834bdad06a195 (commit)
      from  a8a07484d8e33e97525ee6cfe9f4465903a66a5d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 853484a8d2142771ad1484b5a39c58966b63f136
Author: Nikos Mavrogiannopoulos <[email protected]>
Date:   Sat May 26 13:43:38 2012 +0200

    Use windows trusted certificate store.

commit de02e234ae93e1ec9f5716328c8834bdad06a195
Author: Nikos Mavrogiannopoulos <[email protected]>
Date:   Fri May 25 23:44:15 2012 +0200

    Added the notion of a default CRL file.

-----------------------------------------------------------------------

Summary of changes:
 configure.ac      |   11 +++++++
 lib/Makefile.am   |    4 ++
 lib/gnutls_x509.c |   82 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 93 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 075371a..dc74ddd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -296,6 +296,10 @@ AC_ARG_WITH([default-trust-store-file],
   [AS_HELP_STRING([--with-default-trust-store-file=FILE],
     [use the given file default trust store])])
 
+AC_ARG_WITH([default-crl-file],
+  [AS_HELP_STRING([--with-default-crl-file=FILE],
+    [use the given CRL file as default])])
+
 if test "x$with_default_trust_store_pkcs11" = x -a "x$with_default_trust_store_file" = x; then
   # auto detect http://lists.gnu.org/archive/html/help-gnutls/2012-05/msg00004.html
   for i in \
@@ -315,6 +319,11 @@ if test "x$with_default_trust_store_file" != x; then
     ["$with_default_trust_store_file"], [use the given file default trust store])
 fi
 
+if test "x$with_default_crl_file" != x; then
+  AC_DEFINE_UNQUOTED([DEFAULT_CRL_FILE],
+    ["$with_default_crl_file"], [use the given CRL file])
+fi
+
 dnl Guile bindings.
 opt_guile_bindings=yes
 AC_MSG_CHECKING([whether building Guile bindings])
@@ -548,8 +557,10 @@ if features are disabled)
   SRP support:      $ac_enable_srp
   PSK support:      $ac_enable_psk
   Anon auth support:$ac_enable_anon
+
   Trust store pkcs: $with_default_trust_store_pkcs11
   Trust store file: $with_default_trust_store_file
+  CRL file: $with_default_crl_file
 ])
 
 AC_MSG_NOTICE([Optional applications:
diff --git a/lib/Makefile.am b/lib/Makefile.am
index a1e19a1..693af1f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -140,6 +140,10 @@ libgnutls_la_LDFLAGS += $(LTLIBNETTLE)
 libgnutls_la_LIBADD += nettle/libcrypto.la
 endif
 
+if WINDOWS
+libgnutls_la_LDFLAGS += -lcrypt32
+endif
+
 if HAVE_LD_OUTPUT_DEF
 libgnutls_la_LDFLAGS += -Wl,--output-def,libgnutls-$(DLL_VERSION).def
 libgnutls-$(DLL_VERSION).def: libgnutls.la
diff --git a/lib/gnutls_x509.c b/lib/gnutls_x509.c
index 4f15ea1..71e0d69 100644
--- a/lib/gnutls_x509.c
+++ b/lib/gnutls_x509.c
@@ -1588,11 +1588,61 @@ gnutls_certificate_set_x509_trust_file (gnutls_certificate_credentials_t cred,
   return ret;
 }
 
-#ifdef DEFAULT_TRUST_STORE_FILE
+#ifdef _WIN32
 static int
 set_x509_system_trust_file (gnutls_certificate_credentials_t cred)
 {
-  int ret;
+HCERTSTORE store = CertOpenSystemStore(0, "CA");
+const CERT_CONTEXT *cert;
+const CRL_CONTEXT *crl;
+gnutls_datum_t data;
+int ret = 0;
+unsigned int i;
+
+  for (i=0;i<2;i++)
+    {
+    
+      if (i==0) store = CertOpenSystemStore(0, "ROOT");
+      else store = CertOpenSystemStore(0, "CA");
+    
+      if (store == NULL) return GNUTLS_E_FILE_ERROR;
+
+      cert = CertEnumCertificatesInStore(store, NULL);
+      crl = CertEnumCRLsInStore(store, NULL);
+
+      while(cert != NULL) 
+        {
+          if (cert->dwCertEncodingType == X509_ASN_ENCODING)
+            {
+              data.data = cert->pbCertEncoded;
+              data.size = cert->cbCertEncoded;
+              if (gnutls_certificate_set_x509_trust_mem (cred, &data, GNUTLS_X509_FMT_DER) > 0)
+                ret++;
+            }
+          cert = CertEnumCertificatesInStore(store, cert);
+        }
+
+      while(crl != NULL) 
+        {
+          if (crl->dwCertEncodingType == X509_ASN_ENCODING)
+            {
+              data.data = crl->pbCrlEncoded;
+              data.size = crl->cbCrlEncoded;
+            
+              gnutls_certificate_set_x509_crl_mem(cred, &data, GNUTLS_X509_FMT_DER);
+            }
+          crl = CertEnumCRLsInStore(store, crl);
+        }
+      CertCloseStore(store, 0);
+    }
+
+  return ret;
+}
+#elif defined(DEFAULT_TRUST_STORE_FILE)
+static int
+set_x509_system_trust_file (gnutls_certificate_credentials_t cred)
+{
+  int ret, r;
   gnutls_datum_t cas;
   size_t size;
 
@@ -1612,9 +1662,33 @@ set_x509_system_trust_file (gnutls_certificate_credentials_t cred)
   if (ret < 0)
     {
       gnutls_assert ();
+      return ret;
     }
+  
+  r = ret;
 
-  return ret;
+#ifdef DEFAULT_CRL_FILE
+  cas.data = (void*)read_binary_file (DEFAULT_CRL_FILE, &size);
+  if (cas.data == NULL)
+    {
+      gnutls_assert ();
+      return r;
+    }
+
+  cas.size = size;
+
+  ret = gnutls_certificate_set_x509_crl_mem(cred, &cas, GNUTLS_X509_FMT_PEM);
+
+  free (cas.data);
+
+  if (ret < 0)
+    {
+      gnutls_assert ();
+      return ret;
+    }
+#endif
+
+  return r;
 }
 #endif
 
@@ -1636,7 +1710,7 @@ set_x509_system_trust_file (gnutls_certificate_credentials_t cred)
 int
 gnutls_certificate_set_x509_system_trust (gnutls_certificate_credentials_t cred)
 {
-#if !defined(DEFAULT_TRUST_STORE_PKCS11) && !defined(DEFAULT_TRUST_STORE_FILE)
+#if !defined(_WIN32) && !defined(DEFAULT_TRUST_STORE_PKCS11) && !defined(DEFAULT_TRUST_STORE_FILE)
   int r = GNUTLS_E_UNIMPLEMENTED_FEATURE;
 #else
   int ret, r = 0;


hooks/post-receive
-- 
GNU gnutls
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.