]> git.0d.be Git - empathy.git/commitdiff
Add a details hash table as an out param of the verification
authorCosimo Cecchi <cosimoc@gnome.org>
Wed, 18 Aug 2010 14:40:21 +0000 (16:40 +0200)
committerCosimo Cecchi <cosimoc@gnome.org>
Wed, 18 Aug 2010 17:18:56 +0000 (19:18 +0200)
libempathy/empathy-tls-verifier.c
libempathy/empathy-tls-verifier.h

index 55afb40879806c9b6cb9a4a22631ac603e96ca4b..cd76a891728fb0f1c1f2609f5b5ab905e604825d 100644 (file)
@@ -62,6 +62,7 @@ typedef struct {
   gchar *hostname;
 
   GSimpleAsyncResult *verify_result;
+  GHashTable *details;
 
   gboolean dispose_run;
 } EmpathyTLSVerifierPriv;
@@ -271,13 +272,16 @@ real_start_verification (EmpathyTLSVerifier *self)
     {
       gchar *certified_hostname;
 
+      reason = EMP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH;
       certified_hostname = get_certified_hostname (first_cert);
+      tp_asv_set_string (priv->details,
+          "expected-hostname", priv->hostname);
+      tp_asv_set_string (priv->details,
+          "certificate-hostname", certified_hostname);
+
       DEBUG ("Hostname mismatch: got %s but expected %s",
           certified_hostname, priv->hostname);
 
-      /* TODO: pass-through the expected hostname in the reject details */
-      reason = EMP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH;
-
       g_free (certified_hostname);
       goto out;
     }
@@ -622,6 +626,7 @@ empathy_tls_verifier_finalize (GObject *object)
     g_ptr_array_unref (priv->cert_chain);
 
   g_free (priv->hostname);
+  tp_clear_boxed (G_TYPE_HASH_TABLE, &priv->details);
 
   G_OBJECT_CLASS (empathy_tls_verifier_parent_class)->finalize (object);
 }
@@ -640,8 +645,11 @@ empathy_tls_verifier_constructed (GObject *object)
 static void
 empathy_tls_verifier_init (EmpathyTLSVerifier *self)
 {
-  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+  EmpathyTLSVerifierPriv *priv;
+
+  priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
       EMPATHY_TYPE_TLS_VERIFIER, EmpathyTLSVerifierPriv);
+  priv->details = tp_asv_new (NULL, NULL);
 }
 
 static void
@@ -702,15 +710,30 @@ gboolean
 empathy_tls_verifier_verify_finish (EmpathyTLSVerifier *self,
     GAsyncResult *res,
     EmpTLSCertificateRejectReason *reason,
+    GHashTable **details,
     GError **error)
 {
+  EmpathyTLSVerifierPriv *priv = GET_PRIV (self);
+
   if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res),
           error))
     {
-      *reason = (*error)->code;
+      if (reason != NULL)
+        *reason = (*error)->code;
+
+      if (details != NULL)
+        {
+          *details = tp_asv_new (NULL, NULL);
+          tp_g_hash_table_update (*details, priv->details,
+              (GBoxedCopyFunc) g_strdup,
+              (GBoxedCopyFunc) tp_g_value_slice_dup);
+        }
+
       return FALSE;
     }
 
-  *reason = EMP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
+  if (reason != NULL)
+    *reason = EMP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
+
   return TRUE;
 }
index b4cc1fcb79c77257b3cc81e28986ffb43a02aab3..e73a71aeba8b687352c2eb37c273a579f9bcc67c 100644 (file)
@@ -71,6 +71,7 @@ void empathy_tls_verifier_verify_async (EmpathyTLSVerifier *self,
 gboolean empathy_tls_verifier_verify_finish (EmpathyTLSVerifier *self,
     GAsyncResult *res,
     EmpTLSCertificateRejectReason *reason,
+    GHashTable **details,
     GError **error);
 
 G_END_DECLS