FIX TIVI-2641: Fix issue in trusted ports with no valid certificate info. 49/16549/1
authorAmarnath Valluri <amarnath.valluri@linux.intel.com>
Tue, 18 Feb 2014 17:02:14 +0000 (19:02 +0200)
committerAmarnath Valluri <amarnath.valluri@linux.intel.com>
Tue, 18 Feb 2014 17:02:14 +0000 (19:02 +0200)
The case where both sender and receiver has no certificate info case
is not handeld properly, this commit fixes the issue.

Change-Id: I2705a66aea91f7b283dff5d90a2560a70cd116d2

daemon/dbus-manager.c

index d381176..6d6ecde 100644 (file)
@@ -320,8 +320,10 @@ msgport_dbus_manager_validate_peer_certificate (MsgPortDbusManager *dbus_manager
     gboolean is_valid_cert = FALSE;
 
     /* check if the source application has no certificate info */
-    if (dbus_manager->priv->is_null_cert)
+    if (dbus_manager->priv->is_null_cert) {
+        DBG("Service owner has no certifcate information, treating port as untrusted");
         return TRUE; /* allow all peers to connect */
+    }
 
     /* check if we have cached status */
     if (g_hash_table_contains (dbus_manager->priv->peer_certs, peer_app_id))
@@ -334,11 +336,15 @@ msgport_dbus_manager_validate_peer_certificate (MsgPortDbusManager *dbus_manager
         return FALSE;
     }
 
-    if (compare_result == PMINFO_CERT_COMPARE_LHS_NO_CERT) {
+    if (compare_result == PMINFO_CERT_COMPARE_LHS_NO_CERT ||
+        compare_result == PMINFO_CERT_COMPARE_BOTH_NO_CERT) {
+        DBG("Service owner has no certifcate information, treating port as untrusted");
         dbus_manager->priv->is_null_cert = TRUE;
         return TRUE;
     }
 
+    DBG("certificate comparison result : %d", compare_result);
+
     is_valid_cert = (compare_result == PMINFO_CERT_COMPARE_MATCH) ;
     g_hash_table_insert (dbus_manager->priv->peer_certs, g_strdup (peer_app_id), (gpointer)is_valid_cert);