[glib-networking: 68/129] tls: try to find the ca file dynamically on windows
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking: 68/129] tls: try to find the ca file dynamically on windows
- Date: Sat, 2 Feb 2019 22:49:06 +0000 (UTC)
commit 941951eb3e8d41a7b4773719064fdf6be5c583d7
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date: Tue Oct 24 10:14:05 2017 +0200
tls: try to find the ca file dynamically on windows
On windows having the path hardcoded will not work in most
of the cases so we need to try to find it from the installed
directory.
tls/openssl/gtlsbackend-openssl.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/tls/openssl/gtlsbackend-openssl.c b/tls/openssl/gtlsbackend-openssl.c
index 86aa6cb..187608f 100644
--- a/tls/openssl/gtlsbackend-openssl.c
+++ b/tls/openssl/gtlsbackend-openssl.c
@@ -181,14 +181,33 @@ g_tls_backend_openssl_finalize (GObject *object)
static GTlsDatabase *
g_tls_backend_openssl_real_create_database (GTlsBackendOpenssl *self,
- GError **error)
+ GError **error)
{
- const gchar *anchor_file = NULL;
-#ifdef GTLS_SYSTEM_CA_FILE
- /* FIXME: we need to handle this on Windows as well */
- anchor_file = GTLS_SYSTEM_CA_FILE;
+ gchar *anchor_file = NULL;
+ GTlsDatabase *database;
+
+#ifdef G_OS_WIN32
+ gchar *module_dir;
+ gchar *cert_path;
+
+ module_dir = g_win32_get_package_installation_directory_of_module (NULL);
+ cert_path = g_build_filename (module_dir, "bin", "cert.pem", NULL);
+ g_free (module_dir);
+
+ if (g_file_test (cert_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
+ anchor_file = cert_path;
+ else
+ g_free (cert_path);
+#else
+# ifdef GTLS_SYSTEM_CA_FILE
+ anchor_file = g_strdup (GTLS_SYSTEM_CA_FILE);
+# endif
#endif
- return g_tls_file_database_new (anchor_file, error);
+
+ database = g_tls_file_database_new (anchor_file, error);
+ g_free (anchor_file);
+
+ return database;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]