changeset 19271:c28e1afe691b

In x509_ca pool: - Add commentary on the lazy initialization used - Change the CA certs path to DATADIR/purple/ca-certs, as it should be
author William Ehlhardt <williamehlhardt@gmail.com>
date Tue, 14 Aug 2007 06:41:47 +0000
parents fb4a1fb9ce8a
children c861705e934b
files libpurple/certificate.c
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/certificate.c	Tue Aug 14 06:31:50 2007 +0000
+++ b/libpurple/certificate.c	Tue Aug 14 06:41:47 2007 +0000
@@ -609,8 +609,8 @@
 }
 
 /** System directory to probe for CA certificates */
-/* TODO: The current path likely won't work on anything but Debian! Fix! */
-static const gchar *x509_ca_syspath = "/etc/ssl/certs/";
+/* This is set in the lazy_init function */
+static const gchar *x509_ca_syspath = NULL;
 
 /** A list of loaded CAs, populated from the above path whenever the lazy_init
     happens. Contains pointers to x509_ca_elements */
@@ -642,6 +642,14 @@
 	return TRUE;
 }
 
+/* Since the libpurple CertificatePools get registered before plugins are
+   loaded, an X.509 Scheme is generally not available when x509_ca_init is
+   called, but x509_ca requires X.509 operations in order to properly load.
+
+   To solve this, I present the lazy_init function. It attempts to finish
+   initialization of the Pool, but it usually fails when it is called from
+   x509_ca_init. However, this is OK; initialization is then simply deferred
+   until someone tries to use functions from the pool. */
 static gboolean
 x509_ca_lazy_init(void)
 {
@@ -662,6 +670,12 @@
 		return FALSE;
 	}
 
+	/* Attempt to point at the appropriate system path */
+	if (NULL == x509_ca_syspath) {
+		x509_ca_syspath = g_build_filename(DATADIR,
+						   "purple", "ca-certs", NULL);
+	}
+
 	/* Populate the certificates pool from the system path */
 	certdir = g_dir_open(x509_ca_syspath, 0, NULL);
 	g_return_val_if_fail(certdir, FALSE);