]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
some simplifications in gnutls_x509_trust_list_add_system_trust()
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 2 Mar 2013 09:18:45 +0000 (10:18 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 2 Mar 2013 09:18:45 +0000 (10:18 +0100)
lib/Makefile.am
lib/system.c

index a9bd6ff6842bb7aed3452a99a6b888bcbc1e3e9f..a34977c0efd8cb5b0a2ed857dc550a4be38461a3 100644 (file)
@@ -72,7 +72,7 @@ COBJECTS = gnutls_range.c gnutls_record.c \
        gnutls_global.c gnutls_constate.c gnutls_anon_cred.c            \
        $(srcdir)/pkix_asn1_tab.c                               \
        $(srcdir)/gnutls_asn1_tab.c                             \
-       gnutls_mem.c gnutls_ui.c                                        \
+       gnutls_mem.c gnutls_ui.c                                \
        gnutls_sig.c gnutls_ecc.c gnutls_dh_primes.c gnutls_alert.c     \
        system.c gnutls_str.c gnutls_state.c gnutls_x509.c              \
        gnutls_rsa_export.c gnutls_helper.c gnutls_supplemental.c       \
index f42938d2d3623ef425503edf14e7f90bb45550e9..53e2939900051e1d1744a5f365f8fd22cc7fa45c 100644 (file)
@@ -383,36 +383,10 @@ const char *home_dir = getenv ("HOME");
   return 0;
 }
 
-/**
- * gnutls_x509_trust_list_add_system_trust:
- * @list: The structure of the list
- * @tl_flags: GNUTLS_TL_*
- * @tl_vflags: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL
- *
- * This function adds the system's default trusted certificate
- * authorities to the trusted list. Note that on unsupported system
- * this function returns %GNUTLS_E_UNIMPLEMENTED_FEATURE.
- *
- * Returns: The number of added elements or a negative error code on error.
- *
- * Since: 3.1
- **/
-int
-gnutls_x509_trust_list_add_system_trust(gnutls_x509_trust_list_t list,
-                                        unsigned int tl_flags, unsigned int tl_vflags)
+#ifdef _WIN32
+static
+int add_win32_system_trust(gnutls_x509_trust_list_t list, unsigned int tl_flags, unsigned int tl_vflags)
 {
-#if !defined(DEFAULT_TRUST_STORE_PKCS11) && !defined(DEFAULT_TRUST_STORE_FILE) && !defined(_WIN32)
-  return GNUTLS_E_UNIMPLEMENTED_FEATURE;
-#else
-  int ret, r = 0;
-  const char* crl_file = 
-# ifdef DEFAULT_CRL_FILE
-  DEFAULT_CRL_FILE;
-# else
-  NULL;
-# endif
-
-# ifdef _WIN32
   unsigned int i;
 
   for (i=0;i<2;i++)
@@ -454,23 +428,57 @@ gnutls_x509_trust_list_add_system_trust(gnutls_x509_trust_list_t list,
       }
     CertCloseStore(store, 0);
   }
-# endif
+}
+#endif
 
-# if defined(ENABLE_PKCS11) && defined(DEFAULT_TRUST_STORE_PKCS11)
+/**
+ * gnutls_x509_trust_list_add_system_trust:
+ * @list: The structure of the list
+ * @tl_flags: GNUTLS_TL_*
+ * @tl_vflags: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL
+ *
+ * This function adds the system's default trusted certificate
+ * authorities to the trusted list. Note that on unsupported system
+ * this function returns %GNUTLS_E_UNIMPLEMENTED_FEATURE.
+ *
+ * Returns: The number of added elements or a negative error code on error.
+ *
+ * Since: 3.1
+ **/
+int
+gnutls_x509_trust_list_add_system_trust(gnutls_x509_trust_list_t list,
+                                        unsigned int tl_flags, unsigned int tl_vflags)
+{
+#if defined(_WIN32)
+  return add_win32_system_trust(list, tl_flags, tl_vflags);
+#else
+
+# if !defined(DEFAULT_TRUST_STORE_PKCS11) && !defined(DEFAULT_TRUST_STORE_FILE)
+  return GNUTLS_E_UNIMPLEMENTED_FEATURE;
+# else
+  int ret, r = 0;
+  const char* crl_file = 
+#  ifdef DEFAULT_CRL_FILE
+  DEFAULT_CRL_FILE;
+#  else
+  NULL;
+#  endif
+
+#  if defined(ENABLE_PKCS11) && defined(DEFAULT_TRUST_STORE_PKCS11)
   ret = gnutls_x509_trust_list_add_trust_file(list, DEFAULT_TRUST_STORE_PKCS11, crl_file, 
                                               GNUTLS_X509_FMT_DER, tl_flags, tl_vflags);
   if (ret > 0)
     r += ret;
-# endif
+#  endif
 
-# ifdef DEFAULT_TRUST_STORE_FILE
+#  ifdef DEFAULT_TRUST_STORE_FILE
   ret = gnutls_x509_trust_list_add_trust_file(list, DEFAULT_TRUST_STORE_FILE, crl_file, 
                                               GNUTLS_X509_FMT_PEM, tl_flags, tl_vflags);
   if (ret > 0)
     r += ret;
-# endif
+#  endif
   return r;
-#endif
+# endif
 }
 
 #if defined(HAVE_ICONV)