[libgovirt] Allow NULL OvirtProxy::ca-cert property



commit d081c0e7f3e18431309ee8fcf8360546d2d9a316
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Fri Apr 18 13:46:38 2014 +0200

    Allow NULL OvirtProxy::ca-cert property
    
    This can be used to unset a previously set certificate authority.

 govirt/ovirt-proxy.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
index 08bec6f..1ec8d31 100644
--- a/govirt/ovirt-proxy.c
+++ b/govirt/ovirt-proxy.c
@@ -550,15 +550,21 @@ static gboolean set_ca_cert_from_data(OvirtProxy *proxy,
      * the ca-cert property, we need to create a temporary file in order
      * to be able to keep the ssl-ca-file property synced with it
      */
-    char *ca_file_path;
+    char *ca_file_path = NULL;
     GError *error = NULL;
     gboolean result = FALSE;
 
-    ca_file_path = write_to_tmp_file("govirt-ca-XXXXXX.crt", ca_cert_data, ca_cert_len, &error);
-    if (ca_file_path == NULL) {
-        g_warning("Failed to create temporary file for CA certificate: %s",
-                  error->message);
-        goto end;
+    if (ca_cert_data != NULL) {
+        ca_file_path = write_to_tmp_file("govirt-ca-XXXXXX.crt",
+                                         ca_cert_data, ca_cert_len,
+                                         &error);
+        if (ca_file_path == NULL) {
+            g_warning("Failed to create temporary file for CA certificate: %s",
+                      error->message);
+            goto end;
+        }
+    } else {
+        ca_file_path = NULL;
     }
 
     ovirt_proxy_set_tmp_ca_file(proxy, ca_file_path);
@@ -727,7 +733,11 @@ static void ovirt_proxy_set_property(GObject *object,
     case PROP_CA_CERT: {
         GByteArray *ca_cert;
         ca_cert = g_value_get_boxed(value);
-        set_ca_cert_from_data(proxy, (char *)ca_cert->data, ca_cert->len);
+        if (ca_cert != NULL) {
+            set_ca_cert_from_data(proxy, (char *)ca_cert->data, ca_cert->len);
+        } else {
+            set_ca_cert_from_data(proxy, NULL, 0);
+        }
         break;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]