Blame SOURCES/empathy-fix-certificate-validation.patch

433b24
From 7712a50a4c3dfecda6b6401ba5a9dff52a583ecb Mon Sep 17 00:00:00 2001
433b24
From: Debarshi Ray <debarshir@gnome.org>
433b24
Date: Wed, 15 Mar 2017 20:23:43 +0100
433b24
Subject: [PATCH 1/5] tls-verifier: Handle GNUTLS_CERT_REVOKED
433b24
433b24
... by mapping it to TP_TLS_CERTIFICATE_REJECT_REASON_REVOKED.
433b24
433b24
https://bugzilla.gnome.org/show_bug.cgi?id=780160
433b24
---
433b24
 libempathy/empathy-tls-verifier.c | 2 ++
433b24
 1 file changed, 2 insertions(+)
433b24
433b24
diff --git a/libempathy/empathy-tls-verifier.c b/libempathy/empathy-tls-verifier.c
433b24
index fcbc559b3f97..8f80b4372de1 100644
433b24
--- a/libempathy/empathy-tls-verifier.c
433b24
+++ b/libempathy/empathy-tls-verifier.c
433b24
@@ -98,6 +98,8 @@ verification_output_to_reason (gint res,
433b24
         *reason = TP_TLS_CERTIFICATE_REJECT_REASON_NOT_ACTIVATED;
433b24
       else if (verify_output & GNUTLS_CERT_EXPIRED)
433b24
         *reason = TP_TLS_CERTIFICATE_REJECT_REASON_EXPIRED;
433b24
+      else if (verify_output & GNUTLS_CERT_REVOKED)
433b24
+        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_REVOKED;
433b24
       else
433b24
         *reason = TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
433b24
 
433b24
-- 
433b24
2.14.4
433b24
433b24
433b24
From 8c5dc77f406308b77b4a6c7274ff8096091267a6 Mon Sep 17 00:00:00 2001
433b24
From: Debarshi Ray <debarshir@gnome.org>
433b24
Date: Mon, 20 Mar 2017 19:20:11 +0100
433b24
Subject: [PATCH 2/5] tests: Fix comment
433b24
433b24
The existing comment was mistakenly copied from
433b24
test_certificate_verify_success_with_full_chain.
433b24
433b24
This test case is about a certificate that has been pinned against a
433b24
specific peer. The mock TLS connection doesn't have the full chain,
433b24
but just the leaf-level certificate that has been pinned.
433b24
433b24
https://bugzilla.gnome.org/show_bug.cgi?id=780160
433b24
---
433b24
 tests/empathy-tls-test.c | 4 ++--
433b24
 1 file changed, 2 insertions(+), 2 deletions(-)
433b24
433b24
diff --git a/tests/empathy-tls-test.c b/tests/empathy-tls-test.c
433b24
index 91b05761f9b9..0752e1b328c5 100644
433b24
--- a/tests/empathy-tls-test.c
433b24
+++ b/tests/empathy-tls-test.c
433b24
@@ -654,8 +654,8 @@ test_certificate_verify_success_with_pinned (Test *test,
433b24
   };
433b24
 
433b24
   /*
433b24
-   * In this test the mock TLS connection has a full certificate
433b24
-   * chain. We look for an anchor certificate in the chain.
433b24
+   * In this test the mock TLS connection has a certificate that has
433b24
+   * been pinned for the test-server.empathy.gnome.org peer.
433b24
    */
433b24
 
433b24
   test->mock = mock_tls_certificate_new_and_register (test->dbus,
433b24
-- 
433b24
2.14.4
433b24
433b24
433b24
From 6fe06a78a7538cefa2333b180d58b330325796ab Mon Sep 17 00:00:00 2001
433b24
From: Debarshi Ray <debarshir@gnome.org>
433b24
Date: Mon, 20 Mar 2017 19:31:39 +0100
433b24
Subject: [PATCH 3/5] tests: Actually test that hostnames of pinned
433b24
 certificates are verified
433b24
433b24
This test case is about ensuring that a pinned certificate won't be
433b24
validated if the wrong hostname is used.
433b24
433b24
If we don't add the pinned certificate to our database, then checks for
433b24
pinning are going to fail regardless of the hostname being used. The
433b24
correct certificate-hostname pair needs to be in the database to ensure
433b24
that the hostnames are being matched as advertised.
433b24
433b24
https://bugzilla.gnome.org/show_bug.cgi?id=780160
433b24
---
433b24
 tests/empathy-tls-test.c | 3 ++-
433b24
 1 file changed, 2 insertions(+), 1 deletion(-)
433b24
433b24
diff --git a/tests/empathy-tls-test.c b/tests/empathy-tls-test.c
433b24
index 0752e1b328c5..422909e7cc2a 100644
433b24
--- a/tests/empathy-tls-test.c
433b24
+++ b/tests/empathy-tls-test.c
433b24
@@ -695,7 +695,8 @@ test_certificate_verify_pinned_wrong_host (Test *test,
433b24
   test->mock = mock_tls_certificate_new_and_register (test->dbus,
433b24
           "server-cert.cer", NULL);
433b24
 
433b24
-  /* Note that we're not adding any place to find root certs */
433b24
+  /* We add the collabora directory with the collabora root */
433b24
+  add_certificate_to_mock (test, "server-cert.cer", "test-server.empathy.gnome.org");
433b24
 
433b24
   ensure_certificate_proxy (test);
433b24
 
433b24
-- 
433b24
2.14.4
433b24
433b24
433b24
From f07492434449bcdd74a61aa74596884ef5700d88 Mon Sep 17 00:00:00 2001
433b24
From: Debarshi Ray <debarshir@gnome.org>
433b24
Date: Wed, 15 Mar 2017 20:24:08 +0100
433b24
Subject: [PATCH 4/5] tls-verifier: Use GIO to verify the chain of TLS
433b24
 certificates
433b24
433b24
Gcr has its own hand rolled code to complete the certificate chain and
433b24
validate it, which predates the equivalent functionality in GIO. These
433b24
days, GIO's GnuTLS backend is a better option because it defers to
433b24
GnuTLS to do the right thing. It benefits automatically from any
433b24
improvements made to GnuTLS itself.
433b24
433b24
However, GIO doesn't support certificate pinning. Gcr continues to
433b24
provide that feature.
433b24
433b24
Note:
433b24
433b24
(a) We don't set "certificate-hostname" when we encounter
433b24
TP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH. The resulting loss
433b24
of verbosity in EmpathyTLSDialog is balanced by no longer relying on a
433b24
specific encryption library.
433b24
433b24
(b) glib-networking doesn't differentiate between
433b24
GNUTLS_CERT_SIGNER_NOT_FOUND and GNUTLS_CERT_SIGNER_NOT_CA. Hence, we
433b24
club them together as TP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED and we
433b24
no longer return TP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED.
433b24
433b24
(c) Unlike Gcr, GnuTLS doesn't seem to provide a way to load a PKCS#11
433b24
module that's built into the code, as opposed to being a shared object.
433b24
This makes it hard for us to load our mock PKCS#11 module. Therefore,
433b24
we have disabled the test case that relies on using PKCS#11 storage to
433b24
complete the certificate chain.
433b24
433b24
Bump required GLib version to 2.48. We really do need 2.48 because we
433b24
rely on the improvements to GIO's GnuTLS backend.
433b24
433b24
https://bugzilla.gnome.org/show_bug.cgi?id=780160
433b24
---
433b24
 configure.ac                      |   6 +-
433b24
 libempathy/empathy-tls-verifier.c | 419 ++++++++++++++++++--------------------
433b24
 libempathy/empathy-tls-verifier.h |   3 +
433b24
 tests/empathy-tls-test.c          |  35 +++-
433b24
 4 files changed, 232 insertions(+), 231 deletions(-)
433b24
433b24
diff --git a/configure.ac b/configure.ac
433b24
index a427eba3af56..cd6f371de799 100644
433b24
--- a/configure.ac
433b24
+++ b/configure.ac
433b24
@@ -37,9 +37,9 @@ AC_COPYRIGHT([
433b24
 FOLKS_REQUIRED=0.9.5
433b24
 GNUTLS_REQUIRED=2.8.5
433b24
 
433b24
-GLIB_REQUIRED=2.37.6
433b24
-AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_30, [Ignore post 2.30 deprecations])
433b24
-AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_38, [Prevent post 2.38 APIs])
433b24
+GLIB_REQUIRED=2.48.0
433b24
+AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_48, [Ignore post 2.48 deprecations])
433b24
+AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_48, [Prevent post 2.48 APIs])
433b24
 
433b24
 GTK_REQUIRED=3.9.4
433b24
 AC_DEFINE(GDK_VERSION_MIN_REQUIRED, GDK_VERSION_3_8, [Ignore post 3.8 deprecations])
433b24
diff --git a/libempathy/empathy-tls-verifier.c b/libempathy/empathy-tls-verifier.c
433b24
index 8f80b4372de1..a8306bb569ea 100644
433b24
--- a/libempathy/empathy-tls-verifier.c
433b24
+++ b/libempathy/empathy-tls-verifier.c
433b24
@@ -1,7 +1,9 @@
433b24
 /*
433b24
  * empathy-tls-verifier.c - Source for EmpathyTLSVerifier
433b24
  * Copyright (C) 2010 Collabora Ltd.
433b24
+ * Copyright (C) 2017 Red Hat, Inc.
433b24
  * @author Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
433b24
+ * @author Debarshi Ray <debarshir@gnome.org>
433b24
  * @author Stef Walter <stefw@collabora.co.uk>
433b24
  *
433b24
  * This library is free software; you can redistribute it and/or
433b24
@@ -43,6 +45,8 @@ enum {
433b24
 };
433b24
 
433b24
 typedef struct {
433b24
+  GTlsCertificate *g_certificate;
433b24
+  GTlsDatabase *database;
433b24
   TpTLSCertificate *certificate;
433b24
   gchar *hostname;
433b24
   gchar **reference_identities;
433b24
@@ -53,135 +57,86 @@ typedef struct {
433b24
   gboolean dispose_run;
433b24
 } EmpathyTLSVerifierPriv;
433b24
 
433b24
-static gboolean
433b24
-verification_output_to_reason (gint res,
433b24
-    guint verify_output,
433b24
-    TpTLSCertificateRejectReason *reason)
433b24
+static GTlsCertificate *
433b24
+tls_certificate_new_from_der (GPtrArray *data, GError **error)
433b24
 {
433b24
-  gboolean retval = TRUE;
433b24
+  GTlsBackend *tls_backend;
433b24
+  GTlsCertificate *cert = NULL;
433b24
+  GTlsCertificate *issuer = NULL;
433b24
+  GTlsCertificate *retval = NULL;
433b24
+  GType tls_certificate_type;
433b24
+  gint i;
433b24
 
433b24
-  g_assert (reason != NULL);
433b24
+  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
433b24
 
433b24
-  if (res != GNUTLS_E_SUCCESS)
433b24
-    {
433b24
-      retval = FALSE;
433b24
+  tls_backend = g_tls_backend_get_default ();
433b24
+  tls_certificate_type = g_tls_backend_get_certificate_type (tls_backend);
433b24
 
433b24
-      /* the certificate is not structurally valid */
433b24
-      switch (res)
433b24
-        {
433b24
-        case GNUTLS_E_INSUFFICIENT_CREDENTIALS:
433b24
-          *reason = TP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED;
433b24
-          break;
433b24
-        case GNUTLS_E_CONSTRAINT_ERROR:
433b24
-          *reason = TP_TLS_CERTIFICATE_REJECT_REASON_LIMIT_EXCEEDED;
433b24
-          break;
433b24
-        default:
433b24
-          *reason = TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
433b24
-          break;
433b24
-        }
433b24
-
433b24
-      goto out;
433b24
+  for (i = (gint) data->len - 1; i >= 0; --i)
433b24
+    {
433b24
+      GArray *cert_data;
433b24
+
433b24
+      cert_data = g_ptr_array_index (data, i);
433b24
+      cert = g_initable_new (tls_certificate_type,
433b24
+          NULL,
433b24
+          error,
433b24
+          "certificate", (GByteArray *) cert_data,
433b24
+          "issuer", issuer,
433b24
+          NULL);
433b24
+
433b24
+      if (cert == NULL)
433b24
+        goto out;
433b24
+
433b24
+      g_clear_object (&issuer);
433b24
+      issuer = g_object_ref (cert);
433b24
+      g_clear_object (&cert);
433b24
     }
433b24
 
433b24
-  /* the certificate is structurally valid, check for other errors. */
433b24
-  if (verify_output & GNUTLS_CERT_INVALID)
433b24
-    {
433b24
-      retval = FALSE;
433b24
-
433b24
-      if (verify_output & GNUTLS_CERT_SIGNER_NOT_FOUND)
433b24
-        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED;
433b24
-      else if (verify_output & GNUTLS_CERT_SIGNER_NOT_CA)
433b24
-        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED;
433b24
-      else if (verify_output & GNUTLS_CERT_INSECURE_ALGORITHM)
433b24
-        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_INSECURE;
433b24
-      else if (verify_output & GNUTLS_CERT_NOT_ACTIVATED)
433b24
-        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_NOT_ACTIVATED;
433b24
-      else if (verify_output & GNUTLS_CERT_EXPIRED)
433b24
-        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_EXPIRED;
433b24
-      else if (verify_output & GNUTLS_CERT_REVOKED)
433b24
-        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_REVOKED;
433b24
-      else
433b24
-        *reason = TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
433b24
+  g_assert_null (cert);
433b24
+  g_assert_true (G_IS_TLS_CERTIFICATE (issuer));
433b24
 
433b24
-      goto out;
433b24
-    }
433b24
+  retval = g_object_ref (issuer);
433b24
 
433b24
  out:
433b24
+  g_clear_object (&cert);
433b24
+  g_clear_object (&issuer);
433b24
   return retval;
433b24
 }
433b24
 
433b24
-static void
433b24
-build_certificate_list_for_gnutls (GcrCertificateChain *chain,
433b24
-        gnutls_x509_crt_t **list,
433b24
-        guint *n_list,
433b24
-        gnutls_x509_crt_t **anchors,
433b24
-        guint *n_anchors)
433b24
+static TpTLSCertificateRejectReason
433b24
+verification_output_to_reason (GTlsCertificateFlags flags)
433b24
 {
433b24
-  GcrCertificate *cert;
433b24
-  guint idx, length;
433b24
-  gnutls_x509_crt_t *retval;
433b24
-  gnutls_x509_crt_t gcert;
433b24
-  gnutls_datum_t datum;
433b24
-  gsize n_data;
433b24
-
433b24
-  g_assert (list);
433b24
-  g_assert (n_list);
433b24
-  g_assert (anchors);
433b24
-  g_assert (n_anchors);
433b24
+  TpTLSCertificateRejectReason retval;
433b24
 
433b24
-  *list = *anchors = NULL;
433b24
-  *n_list = *n_anchors = 0;
433b24
+  g_assert (flags != 0);
433b24
 
433b24
-  length = gcr_certificate_chain_get_length (chain);
433b24
-  retval = g_malloc0 (sizeof (gnutls_x509_crt_t) * length);
433b24
-
433b24
-  /* Convert the main body of the chain to gnutls */
433b24
-  for (idx = 0; idx < length; ++idx)
433b24
-    {
433b24
-      cert = gcr_certificate_chain_get_certificate (chain, idx);
433b24
-      datum.data = (gpointer)gcr_certificate_get_der_data (cert, &n_data);
433b24
-      datum.size = n_data;
433b24
-
433b24
-      gnutls_x509_crt_init (&gcert);
433b24
-      if (gnutls_x509_crt_import (gcert, &datum, GNUTLS_X509_FMT_DER) < 0)
433b24
-        g_return_if_reached ();
433b24
-
433b24
-      retval[idx] = gcert;
433b24
-    }
433b24
-
433b24
-  *list = retval;
433b24
-  *n_list = length;
433b24
-
433b24
-  /* See if we have an anchor */
433b24
-  if (gcr_certificate_chain_get_status (chain) ==
433b24
-          GCR_CERTIFICATE_CHAIN_ANCHORED)
433b24
+  switch (flags)
433b24
     {
433b24
-      cert = gcr_certificate_chain_get_anchor (chain);
433b24
-      g_return_if_fail (cert);
433b24
-
433b24
-      datum.data = (gpointer)gcr_certificate_get_der_data (cert, &n_data);
433b24
-      datum.size = n_data;
433b24
-
433b24
-      gnutls_x509_crt_init (&gcert);
433b24
-      if (gnutls_x509_crt_import (gcert, &datum, GNUTLS_X509_FMT_DER) < 0)
433b24
-        g_return_if_reached ();
433b24
-
433b24
-      retval = g_malloc0 (sizeof (gnutls_x509_crt_t) * 1);
433b24
-      retval[0] = gcert;
433b24
-      *anchors = retval;
433b24
-      *n_anchors = 1;
433b24
+      case G_TLS_CERTIFICATE_UNKNOWN_CA:
433b24
+        retval = TP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED;
433b24
+        break;
433b24
+      case G_TLS_CERTIFICATE_BAD_IDENTITY:
433b24
+        retval = TP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH;
433b24
+        break;
433b24
+      case G_TLS_CERTIFICATE_NOT_ACTIVATED:
433b24
+        retval = TP_TLS_CERTIFICATE_REJECT_REASON_NOT_ACTIVATED;
433b24
+        break;
433b24
+      case G_TLS_CERTIFICATE_EXPIRED:
433b24
+        retval = TP_TLS_CERTIFICATE_REJECT_REASON_EXPIRED;
433b24
+        break;
433b24
+      case G_TLS_CERTIFICATE_REVOKED:
433b24
+        retval = TP_TLS_CERTIFICATE_REJECT_REASON_REVOKED;
433b24
+        break;
433b24
+      case G_TLS_CERTIFICATE_INSECURE:
433b24
+        retval = TP_TLS_CERTIFICATE_REJECT_REASON_INSECURE;
433b24
+        break;
433b24
+      case G_TLS_CERTIFICATE_GENERIC_ERROR:
433b24
+      default:
433b24
+        retval = TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
433b24
+        break;
433b24
     }
433b24
-}
433b24
 
433b24
-static void
433b24
-free_certificate_list_for_gnutls (gnutls_x509_crt_t *list,
433b24
-        guint n_list)
433b24
-{
433b24
-  guint idx;
433b24
-
433b24
-  for (idx = 0; idx < n_list; idx++)
433b24
-    gnutls_x509_crt_deinit (list[idx]);
433b24
-  g_free (list);
433b24
+  return retval;
433b24
 }
433b24
 
433b24
 static void
433b24
@@ -193,6 +148,7 @@ complete_verification (EmpathyTLSVerifier *self)
433b24
 
433b24
   g_simple_async_result_complete_in_idle (priv->verify_result);
433b24
 
433b24
+  g_clear_object (&priv->g_certificate);
433b24
   tp_clear_object (&priv->verify_result);
433b24
 }
433b24
 
433b24
@@ -209,6 +165,7 @@ abort_verification (EmpathyTLSVerifier *self,
433b24
       reason);
433b24
   g_simple_async_result_complete_in_idle (priv->verify_result);
433b24
 
433b24
+  g_clear_object (&priv->g_certificate);
433b24
   tp_clear_object (&priv->verify_result);
433b24
 }
433b24
 
433b24
@@ -221,142 +178,137 @@ debug_certificate (GcrCertificate *cert)
433b24
 }
433b24
 
433b24
 static void
433b24
-debug_certificate_chain (GcrCertificateChain *chain)
433b24
+verify_chain_cb (GObject *object,
433b24
+        GAsyncResult *res,
433b24
+        gpointer user_data)
433b24
 {
433b24
-    GEnumClass *enum_class;
433b24
-    GEnumValue *enum_value;
433b24
-    gint idx, length;
433b24
-    GcrCertificate *cert;
433b24
-
433b24
-    enum_class = G_ENUM_CLASS
433b24
-            (g_type_class_peek (GCR_TYPE_CERTIFICATE_CHAIN_STATUS));
433b24
-    enum_value = g_enum_get_value (enum_class,
433b24
-            gcr_certificate_chain_get_status (chain));
433b24
-    length = gcr_certificate_chain_get_length (chain);
433b24
-    DEBUG ("Certificate chain: length %u status %s",
433b24
-            length, enum_value ? enum_value->value_nick : "XXX");
433b24
-
433b24
-    for (idx = 0; idx < length; ++idx)
433b24
-      {
433b24
-        cert = gcr_certificate_chain_get_certificate (chain, idx);
433b24
-        debug_certificate (cert);
433b24
-      }
433b24
-}
433b24
+  GError *error = NULL;
433b24
 
433b24
-static void
433b24
-perform_verification (EmpathyTLSVerifier *self,
433b24
-        GcrCertificateChain *chain)
433b24
-{
433b24
-  gboolean ret = FALSE;
433b24
-  TpTLSCertificateRejectReason reason =
433b24
-    TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN;
433b24
-  gnutls_x509_crt_t *list, *anchors;
433b24
-  guint n_list, n_anchors;
433b24
-  guint verify_output;
433b24
-  gint res;
433b24
+  GTlsCertificateFlags flags;
433b24
+  GTlsDatabase *tls_database = G_TLS_DATABASE (object);
433b24
   gint i;
433b24
-  gboolean matched = FALSE;
433b24
+  EmpathyTLSVerifier *self = EMPATHY_TLS_VERIFIER (user_data);
433b24
   EmpathyTLSVerifierPriv *priv = GET_PRIV (self);
433b24
 
433b24
-  DEBUG ("Performing verification");
433b24
-  debug_certificate_chain (chain);
433b24
-
433b24
-  list = anchors = NULL;
433b24
-  n_list = n_anchors = 0;
433b24
-
433b24
-  /*
433b24
-   * If the first certificate is an pinned certificate then we completely
433b24
-   * ignore the rest of the verification process.
433b24
+  /* FIXME: g_tls_database_verify_chain doesn't set the GError if the
433b24
+   * certificate chain couldn't be verified. See:
433b24
+   * https://bugzilla.gnome.org/show_bug.cgi?id=780310
433b24
    */
433b24
-  if (gcr_certificate_chain_get_status (chain) == GCR_CERTIFICATE_CHAIN_PINNED)
433b24
+  flags = g_tls_database_verify_chain_finish (tls_database, res, &error);
433b24
+  if (flags != 0)
433b24
     {
433b24
-      DEBUG ("Found pinned certificate for %s", priv->hostname);
433b24
-      complete_verification (self);
433b24
-      goto out;
433b24
-  }
433b24
-
433b24
-  build_certificate_list_for_gnutls (chain, &list, &n_list,
433b24
-          &anchors, &n_anchors);
433b24
-  if (list == NULL || n_list == 0) {
433b24
-      g_warn_if_reached ();
433b24
-      abort_verification (self, TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN);
433b24
-      goto out;
433b24
-  }
433b24
+      TpTLSCertificateRejectReason reason;
433b24
 
433b24
-  verify_output = 0;
433b24
-  res = gnutls_x509_crt_list_verify (list, n_list, anchors, n_anchors,
433b24
-           NULL, 0, 0, &verify_output);
433b24
-  ret = verification_output_to_reason (res, verify_output, &reason);
433b24
+      /* We don't pass the identity to g_tls_database_verify. */
433b24
+      g_assert_false (flags & G_TLS_CERTIFICATE_BAD_IDENTITY);
433b24
 
433b24
-  DEBUG ("Certificate verification gave result %d with reason %u", ret,
433b24
+      reason = verification_output_to_reason (flags);
433b24
+      DEBUG ("Certificate verification gave flags %d with reason %u",
433b24
+          (gint) flags,
433b24
           reason);
433b24
 
433b24
-  if (!ret) {
433b24
       abort_verification (self, reason);
433b24
+      g_clear_error (&error);
433b24
       goto out;
433b24
-  }
433b24
+    }
433b24
 
433b24
-  /* now check if the certificate matches one of the reference identities. */
433b24
-  if (priv->reference_identities != NULL)
433b24
+  for (i = 0; priv->reference_identities[i] != NULL; i++)
433b24
     {
433b24
-      for (i = 0, matched = FALSE; priv->reference_identities[i] != NULL; ++i)
433b24
-        {
433b24
-          if (gnutls_x509_crt_check_hostname (list[0],
433b24
-                  priv->reference_identities[i]) == 1)
433b24
-            {
433b24
-              matched = TRUE;
433b24
-              break;
433b24
-            }
433b24
-        }
433b24
+      GSocketConnectable *identity = NULL;
433b24
+
433b24
+      identity = g_network_address_new (priv->reference_identities[i], 0);
433b24
+      flags = g_tls_certificate_verify (priv->g_certificate, identity, NULL);
433b24
+
433b24
+      g_object_unref (identity);
433b24
+      if (flags == 0)
433b24
+        break;
433b24
     }
433b24
 
433b24
-  if (!matched)
433b24
+  if (flags != 0)
433b24
     {
433b24
-      gchar *certified_hostname;
433b24
+      TpTLSCertificateRejectReason reason;
433b24
+
433b24
+      g_assert_cmpint (flags, ==, G_TLS_CERTIFICATE_BAD_IDENTITY);
433b24
+
433b24
+      reason = verification_output_to_reason (flags);
433b24
+      DEBUG ("Certificate verification gave flags %d with reason %u",
433b24
+          (gint) flags,
433b24
+          reason);
433b24
 
433b24
-      certified_hostname = empathy_get_x509_certificate_hostname (list[0]);
433b24
-      tp_asv_set_string (priv->details,
433b24
-          "expected-hostname", priv->hostname);
433b24
-      tp_asv_set_string (priv->details,
433b24
-          "certificate-hostname", certified_hostname);
433b24
+      /* FIXME: We don't set "certificate-hostname" because
433b24
+       * GTlsCertificate doesn't expose the hostname used in the
433b24
+       * certificate. We will temporarily lose some verbosity in
433b24
+       * EmpathyTLSDialog, but that's balanced by no longer
433b24
+       * relying on a specific encryption library.
433b24
+       */
433b24
+      tp_asv_set_string (priv->details, "expected-hostname", priv->hostname);
433b24
 
433b24
-      DEBUG ("Hostname mismatch: got %s but expected %s",
433b24
-          certified_hostname, priv->hostname);
433b24
+      DEBUG ("Hostname mismatch: expected %s", priv->hostname);
433b24
 
433b24
-      g_free (certified_hostname);
433b24
-      abort_verification (self,
433b24
-              TP_TLS_CERTIFICATE_REJECT_REASON_HOSTNAME_MISMATCH);
433b24
+      abort_verification (self, reason);
433b24
       goto out;
433b24
     }
433b24
 
433b24
-  DEBUG ("Hostname matched");
433b24
+  DEBUG ("Verified certificate chain");
433b24
   complete_verification (self);
433b24
 
433b24
- out:
433b24
-  free_certificate_list_for_gnutls (list, n_list);
433b24
-  free_certificate_list_for_gnutls (anchors, n_anchors);
433b24
+out:
433b24
+  /* Matches ref when starting verify chain */
433b24
+  g_object_unref (self);
433b24
 }
433b24
 
433b24
 static void
433b24
-perform_verification_cb (GObject *object,
433b24
-        GAsyncResult *res,
433b24
-        gpointer user_data)
433b24
+is_certificate_pinned_cb (GObject *object,
433b24
+    GAsyncResult *res,
433b24
+    gpointer user_data)
433b24
 {
433b24
   GError *error = NULL;
433b24
-
433b24
-  GcrCertificateChain *chain = GCR_CERTIFICATE_CHAIN (object);
433b24
+  GPtrArray *cert_data;
433b24
   EmpathyTLSVerifier *self = EMPATHY_TLS_VERIFIER (user_data);
433b24
+  EmpathyTLSVerifierPriv *priv = GET_PRIV (self);
433b24
+
433b24
+  if (gcr_trust_is_certificate_pinned_finish (res, &error))
433b24
+    {
433b24
+      DEBUG ("Found pinned certificate for %s", priv->hostname);
433b24
+      complete_verification (self);
433b24
+      goto out;
433b24
+    }
433b24
+
433b24
+  /* error is set only when there is an actual failure. It won't be
433b24
+   * set, if it successfully determined that the ceritificate was not
433b24
+   * pinned. */
433b24
+  if (error != NULL)
433b24
+    {
433b24
+      DEBUG ("Failed to determine if certificate is pinned: %s",
433b24
+          error->message);
433b24
+      g_clear_error (&error);
433b24
+    }
433b24
 
433b24
-  /* Even if building the chain fails, try verifying what we have */
433b24
-  if (!gcr_certificate_chain_build_finish (chain, res, &error))
433b24
+  cert_data = tp_tls_certificate_get_cert_data (priv->certificate);
433b24
+  priv->g_certificate = tls_certificate_new_from_der (cert_data, &error);
433b24
+  if (error != NULL)
433b24
     {
433b24
-      DEBUG ("Building of certificate chain failed: %s", error->message);
433b24
+      DEBUG ("Verification of certificate chain failed: %s", error->message);
433b24
+
433b24
+      abort_verification (self, TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN);
433b24
       g_clear_error (&error);
433b24
+      goto out;
433b24
     }
433b24
 
433b24
-  perform_verification (self, chain);
433b24
+  DEBUG ("Performing verification");
433b24
+
433b24
+  g_tls_database_verify_chain_async (priv->database,
433b24
+      priv->g_certificate,
433b24
+      G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER,
433b24
+      NULL,
433b24
+      NULL,
433b24
+      G_TLS_DATABASE_VERIFY_NONE,
433b24
+      NULL,
433b24
+      verify_chain_cb,
433b24
+      g_object_ref (self));
433b24
 
433b24
-  /* Matches ref when staring chain build */
433b24
+out:
433b24
+  /* Matches ref when starting is certificate pinned */
433b24
   g_object_unref (self);
433b24
 }
433b24
 
433b24
@@ -420,6 +372,8 @@ empathy_tls_verifier_dispose (GObject *object)
433b24
 
433b24
   priv->dispose_run = TRUE;
433b24
 
433b24
+  g_clear_object (&priv->g_certificate);
433b24
+  g_clear_object (&priv->database);
433b24
   tp_clear_object (&priv->certificate);
433b24
 
433b24
   G_OBJECT_CLASS (empathy_tls_verifier_parent_class)->dispose (object);
433b24
@@ -443,10 +397,14 @@ static void
433b24
 empathy_tls_verifier_init (EmpathyTLSVerifier *self)
433b24
 {
433b24
   EmpathyTLSVerifierPriv *priv;
433b24
+  GTlsBackend *tls_backend;
433b24
 
433b24
   priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
433b24
       EMPATHY_TYPE_TLS_VERIFIER, EmpathyTLSVerifierPriv);
433b24
   priv->details = tp_asv_new (NULL, NULL);
433b24
+
433b24
+  tls_backend = g_tls_backend_get_default ();
433b24
+  priv->database = g_tls_backend_get_default_database (tls_backend);
433b24
 }
433b24
 
433b24
 static void
433b24
@@ -503,16 +461,15 @@ empathy_tls_verifier_verify_async (EmpathyTLSVerifier *self,
433b24
     GAsyncReadyCallback callback,
433b24
     gpointer user_data)
433b24
 {
433b24
-  GcrCertificateChain *chain;
433b24
   GcrCertificate *cert;
433b24
   GPtrArray *cert_data;
433b24
   GArray *data;
433b24
-  guint idx;
433b24
   EmpathyTLSVerifierPriv *priv = GET_PRIV (self);
433b24
 
433b24
   DEBUG ("Starting verification");
433b24
 
433b24
   g_return_if_fail (priv->verify_result == NULL);
433b24
+  g_return_if_fail (priv->g_certificate == NULL);
433b24
 
433b24
   cert_data = tp_tls_certificate_get_cert_data (priv->certificate);
433b24
   g_return_if_fail (cert_data);
433b24
@@ -520,19 +477,22 @@ empathy_tls_verifier_verify_async (EmpathyTLSVerifier *self,
433b24
   priv->verify_result = g_simple_async_result_new (G_OBJECT (self),
433b24
       callback, user_data, NULL);
433b24
 
433b24
-  /* Create a certificate chain */
433b24
-  chain = gcr_certificate_chain_new ();
433b24
-  for (idx = 0; idx < cert_data->len; ++idx) {
433b24
-    data = g_ptr_array_index (cert_data, idx);
433b24
-    cert = gcr_simple_certificate_new ((guchar *) data->data, data->len);
433b24
-    gcr_certificate_chain_add (chain, cert);
433b24
-    g_object_unref (cert);
433b24
-  }
433b24
+  /* The first certificate in the chain is for the host */
433b24
+  data = g_ptr_array_index (cert_data, 0);
433b24
+  cert = gcr_simple_certificate_new ((gpointer) data->data,
433b24
+      (gsize) data->len);
433b24
+
433b24
+  DEBUG ("Checking if certificate is pinned:");
433b24
+  debug_certificate (cert);
433b24
 
433b24
-  gcr_certificate_chain_build_async (chain, GCR_PURPOSE_SERVER_AUTH, priv->hostname, 0,
433b24
-          NULL, perform_verification_cb, g_object_ref (self));
433b24
+  gcr_trust_is_certificate_pinned_async (cert,
433b24
+      GCR_PURPOSE_SERVER_AUTH,
433b24
+      priv->hostname,
433b24
+      NULL,
433b24
+      is_certificate_pinned_cb,
433b24
+      g_object_ref (self));
433b24
 
433b24
-  g_object_unref (chain);
433b24
+  g_object_unref (cert);
433b24
 }
433b24
 
433b24
 gboolean
433b24
@@ -567,6 +527,21 @@ empathy_tls_verifier_verify_finish (EmpathyTLSVerifier *self,
433b24
   return TRUE;
433b24
 }
433b24
 
433b24
+void empathy_tls_verifier_set_database (EmpathyTLSVerifier *self,
433b24
+    GTlsDatabase *database)
433b24
+{
433b24
+  EmpathyTLSVerifierPriv *priv = GET_PRIV (self);
433b24
+
433b24
+  g_return_if_fail (EMPATHY_IS_TLS_VERIFIER (self));
433b24
+  g_return_if_fail (G_IS_TLS_DATABASE (database));
433b24
+
433b24
+  if (database == priv->database)
433b24
+    return;
433b24
+
433b24
+  g_clear_object (&priv->database);
433b24
+  priv->database = g_object_ref (database);
433b24
+}
433b24
+
433b24
 void
433b24
 empathy_tls_verifier_store_exception (EmpathyTLSVerifier *self)
433b24
 {
433b24
diff --git a/libempathy/empathy-tls-verifier.h b/libempathy/empathy-tls-verifier.h
433b24
index c25d9756cb02..f9bf54a612f2 100644
433b24
--- a/libempathy/empathy-tls-verifier.h
433b24
+++ b/libempathy/empathy-tls-verifier.h
433b24
@@ -72,6 +72,9 @@ gboolean empathy_tls_verifier_verify_finish (EmpathyTLSVerifier *self,
433b24
     GHashTable **details,
433b24
     GError **error);
433b24
 
433b24
+void empathy_tls_verifier_set_database (EmpathyTLSVerifier *self,
433b24
+    GTlsDatabase *database);
433b24
+
433b24
 void empathy_tls_verifier_store_exception (EmpathyTLSVerifier *self);
433b24
 
433b24
 G_END_DECLS
433b24
diff --git a/tests/empathy-tls-test.c b/tests/empathy-tls-test.c
433b24
index 422909e7cc2a..b8f9ffcbb9af 100644
433b24
--- a/tests/empathy-tls-test.c
433b24
+++ b/tests/empathy-tls-test.c
433b24
@@ -270,6 +270,7 @@ mock_tls_certificate_new_and_register (TpDBusDaemon *dbus,
433b24
 
433b24
 typedef struct {
433b24
   GMainLoop *loop;
433b24
+  GTlsDatabase *database;
433b24
   TpDBusDaemon *dbus;
433b24
   const gchar *dbus_name;
433b24
   MockTLSCertificate *mock;
433b24
@@ -283,9 +284,18 @@ setup (Test *test, gconstpointer data)
433b24
   GError *error = NULL;
433b24
   GckModule *module;
433b24
   const gchar *trust_uris[2] = { MOCK_SLOT_ONE_URI, NULL };
433b24
+  gchar *path = NULL;
433b24
 
433b24
   test->loop = g_main_loop_new (NULL, FALSE);
433b24
 
433b24
+  path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"),
433b24
+      "tests",
433b24
+      "certificates",
433b24
+      "certificate-authority.pem",
433b24
+      NULL);
433b24
+  test->database = g_tls_file_database_new (path, &error);
433b24
+  g_assert_no_error (error);
433b24
+
433b24
   test->dbus = tp_dbus_daemon_dup (&error);
433b24
   g_assert_no_error (error);
433b24
 
433b24
@@ -301,6 +311,8 @@ setup (Test *test, gconstpointer data)
433b24
   gcr_pkcs11_set_modules (NULL);
433b24
   gcr_pkcs11_add_module (module);
433b24
   gcr_pkcs11_set_trust_lookup_uris (trust_uris);
433b24
+
433b24
+  g_free (path);
433b24
 }
433b24
 
433b24
 static void
433b24
@@ -325,6 +337,8 @@ teardown (Test *test, gconstpointer data)
433b24
     g_object_unref (test->cert);
433b24
   test->cert = NULL;
433b24
 
433b24
+  g_clear_object (&test->database);
433b24
+
433b24
   g_main_loop_unref (test->loop);
433b24
   test->loop = NULL;
433b24
 
433b24
@@ -418,6 +432,8 @@ test_certificate_mock_basics (Test *test,
433b24
   g_assert (test->mock->state == TP_TLS_CERTIFICATE_STATE_ACCEPTED);
433b24
 }
433b24
 
433b24
+#if 0
433b24
+
433b24
 static void
433b24
 test_certificate_verify_success_with_pkcs11_lookup (Test *test,
433b24
         gconstpointer data G_GNUC_UNUSED)
433b24
@@ -459,6 +475,8 @@ test_certificate_verify_success_with_pkcs11_lookup (Test *test,
433b24
   g_object_unref (verifier);
433b24
 }
433b24
 
433b24
+#endif
433b24
+
433b24
 static void
433b24
 test_certificate_verify_success_with_full_chain (Test *test,
433b24
         gconstpointer data G_GNUC_UNUSED)
433b24
@@ -486,6 +504,7 @@ test_certificate_verify_success_with_full_chain (Test *test,
433b24
 
433b24
   verifier = empathy_tls_verifier_new (test->cert, "test-server.empathy.gnome.org",
433b24
       reference_identities);
433b24
+  empathy_tls_verifier_set_database (verifier, test->database);
433b24
   empathy_tls_verifier_verify_async (verifier, fetch_callback_result, test);
433b24
   g_main_loop_run (test->loop);
433b24
   empathy_tls_verifier_verify_finish (verifier, test->result, &reason,
433b24
@@ -525,9 +544,9 @@ test_certificate_verify_root_not_found (Test *test,
433b24
   empathy_tls_verifier_verify_finish (verifier, test->result, &reason,
433b24
       NULL, &error);
433b24
 
433b24
-  /* And it should say we're self-signed (oddly enough) */
433b24
+  /* And it should say we're untrusted */
433b24
   g_assert_error (error, G_IO_ERROR,
433b24
-      TP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED);
433b24
+      TP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED);
433b24
 
433b24
   g_clear_error (&error);
433b24
   g_object_unref (verifier);
433b24
@@ -560,9 +579,9 @@ test_certificate_verify_root_not_anchored (Test *test,
433b24
   empathy_tls_verifier_verify_finish (verifier, test->result, &reason,
433b24
       NULL, &error);
433b24
 
433b24
-  /* And it should say we're self-signed (oddly enough) */
433b24
+  /* And it should say we're untrusted */
433b24
   g_assert_error (error, G_IO_ERROR,
433b24
-      TP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED);
433b24
+      TP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED);
433b24
 
433b24
   g_clear_error (&error);
433b24
   g_object_unref (verifier);
433b24
@@ -590,6 +609,7 @@ test_certificate_verify_identities_invalid (Test *test,
433b24
 
433b24
   verifier = empathy_tls_verifier_new (test->cert, "invalid.host.name",
433b24
       reference_identities);
433b24
+  empathy_tls_verifier_set_database (verifier, test->database);
433b24
   empathy_tls_verifier_verify_async (verifier, fetch_callback_result, test);
433b24
   g_main_loop_run (test->loop);
433b24
 
433b24
@@ -627,6 +647,7 @@ test_certificate_verify_uses_reference_identities (Test *test,
433b24
   /* Should be using the reference_identities and not host name for checks */
433b24
   verifier = empathy_tls_verifier_new (test->cert, "test-server.empathy.gnome.org",
433b24
       reference_identities);
433b24
+  empathy_tls_verifier_set_database (verifier, test->database);
433b24
   empathy_tls_verifier_verify_async (verifier, fetch_callback_result, test);
433b24
   g_main_loop_run (test->loop);
433b24
 
433b24
@@ -708,9 +729,9 @@ test_certificate_verify_pinned_wrong_host (Test *test,
433b24
   empathy_tls_verifier_verify_finish (verifier, test->result, &reason,
433b24
       NULL, &error);
433b24
 
433b24
-  /* And it should say we're self-signed */
433b24
+  /* And it should say we're untrusted */
433b24
   g_assert_error (error, G_IO_ERROR,
433b24
-      TP_TLS_CERTIFICATE_REJECT_REASON_SELF_SIGNED);
433b24
+      TP_TLS_CERTIFICATE_REJECT_REASON_UNTRUSTED);
433b24
 
433b24
   g_clear_error (&error);
433b24
   g_object_unref (verifier);
433b24
@@ -727,8 +748,10 @@ main (int argc,
433b24
 
433b24
   g_test_add ("/tls/certificate_basics", Test, NULL,
433b24
           setup, test_certificate_mock_basics, teardown);
433b24
+#if 0
433b24
   g_test_add ("/tls/certificate_verify_success_with_pkcs11_lookup", Test, NULL,
433b24
           setup, test_certificate_verify_success_with_pkcs11_lookup, teardown);
433b24
+#endif
433b24
   g_test_add ("/tls/certificate_verify_success_with_full_chain", Test, NULL,
433b24
           setup, test_certificate_verify_success_with_full_chain, teardown);
433b24
   g_test_add ("/tls/certificate_verify_root_not_found", Test, NULL,
433b24
-- 
433b24
2.14.4
433b24
433b24
433b24
From a5ef984c6219070253f382d41101de9f904563c6 Mon Sep 17 00:00:00 2001
433b24
From: Debarshi Ray <debarshir@gnome.org>
433b24
Date: Thu, 16 Mar 2017 19:50:40 +0100
433b24
Subject: [PATCH 5/5] Remove the GnuTLS dependency
433b24
433b24
GIO, backed by glib-networking, has everything that we need.
433b24
433b24
https://bugzilla.gnome.org/show_bug.cgi?id=780160
433b24
---
433b24
 configure.ac               |  2 --
433b24
 libempathy/empathy-utils.c | 35 -----------------------------------
433b24
 libempathy/empathy-utils.h |  3 ---
433b24
 src/empathy-auth-client.c  |  2 --
433b24
 tests/empathy-tls-test.c   |  2 --
433b24
 5 files changed, 44 deletions(-)
433b24
433b24
diff --git a/configure.ac b/configure.ac
433b24
index cd6f371de799..a1cd48687e27 100644
433b24
--- a/configure.ac
433b24
+++ b/configure.ac
433b24
@@ -35,7 +35,6 @@ AC_COPYRIGHT([
433b24
 
433b24
 # Hardp deps
433b24
 FOLKS_REQUIRED=0.9.5
433b24
-GNUTLS_REQUIRED=2.8.5
433b24
 
433b24
 GLIB_REQUIRED=2.48.0
433b24
 AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_48, [Ignore post 2.48 deprecations])
433b24
@@ -219,7 +218,6 @@ PKG_CHECK_MODULES(EMPATHY,
433b24
    gio-2.0 >= $GLIB_REQUIRED
433b24
    gio-unix-2.0 >= $GLIB_REQUIRED
433b24
    libsecret-1 >= $LIBSECRET_REQUIRED
433b24
-   gnutls >= $GNUTLS_REQUIRED
433b24
    gmodule-export-2.0
433b24
    gobject-2.0
433b24
    gsettings-desktop-schemas
433b24
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
433b24
index e8349373639f..88e28b8dd92b 100644
433b24
--- a/libempathy/empathy-utils.c
433b24
+++ b/libempathy/empathy-utils.c
433b24
@@ -20,10 +20,6 @@
433b24
  * Authors: Richard Hult <richard@imendio.com>
433b24
  *          Martyn Russell <martyn@imendio.com>
433b24
  *          Xavier Claessens <xclaesse@gmail.com>
433b24
- *
433b24
- * Some snippets are taken from GnuTLS 2.8.6, which is distributed under the
433b24
- * same GNU Lesser General Public License 2.1 (or later) version. See
433b24
- * empathy_get_x509_certified_hostname ().
433b24
  */
433b24
 
433b24
 #include "config.h"
433b24
@@ -648,37 +644,6 @@ empathy_folks_persona_is_interesting (FolksPersona *persona)
433b24
   return TRUE;
433b24
 }
433b24
 
433b24
-gchar *
433b24
-empathy_get_x509_certificate_hostname (gnutls_x509_crt_t cert)
433b24
-{
433b24
-  gchar dns_name[256];
433b24
-  gsize dns_name_size;
433b24
-  gint idx;
433b24
-  gint res = 0;
433b24
-
433b24
-  /* this snippet is taken from GnuTLS.
433b24
-   * see gnutls/lib/x509/rfc2818_hostname.c
433b24
-   */
433b24
-  for (idx = 0; res >= 0; idx++)
433b24
-    {
433b24
-      dns_name_size = sizeof (dns_name);
433b24
-      res = gnutls_x509_crt_get_subject_alt_name (cert, idx,
433b24
-          dns_name, &dns_name_size, NULL);
433b24
-
433b24
-      if (res == GNUTLS_SAN_DNSNAME || res == GNUTLS_SAN_IPADDRESS)
433b24
-        return g_strndup (dns_name, dns_name_size);
433b24
-    }
433b24
-
433b24
-  dns_name_size = sizeof (dns_name);
433b24
-  res = gnutls_x509_crt_get_dn_by_oid (cert, GNUTLS_OID_X520_COMMON_NAME,
433b24
-      0, 0, dns_name, &dns_name_size);
433b24
-
433b24
-  if (res >= 0)
433b24
-    return g_strndup (dns_name, dns_name_size);
433b24
-
433b24
-  return NULL;
433b24
-}
433b24
-
433b24
 gchar *
433b24
 empathy_format_currency (gint amount,
433b24
     guint scale,
433b24
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
433b24
index a9ff0d89060d..deb3ae87b7aa 100644
433b24
--- a/libempathy/empathy-utils.h
433b24
+++ b/libempathy/empathy-utils.h
433b24
@@ -27,7 +27,6 @@
433b24
 
433b24
 #include <glib.h>
433b24
 #include <glib-object.h>
433b24
-#include <gnutls/x509.h>
433b24
 #include <libxml/tree.h>
433b24
 #include <folks/folks.h>
433b24
 #include <folks/folks-telepathy.h>
433b24
@@ -85,8 +84,6 @@ gboolean empathy_connection_can_group_personas (TpConnection *connection,
433b24
 						FolksIndividual *individual);
433b24
 gboolean empathy_folks_persona_is_interesting (FolksPersona *persona);
433b24
 
433b24
-gchar * empathy_get_x509_certificate_hostname (gnutls_x509_crt_t cert);
433b24
-
433b24
 gchar *empathy_format_currency (gint amount,
433b24
     guint scale,
433b24
     const gchar *currency);
433b24
diff --git a/src/empathy-auth-client.c b/src/empathy-auth-client.c
433b24
index 3ee478d3e29c..6b6482d4b23d 100644
433b24
--- a/src/empathy-auth-client.c
433b24
+++ b/src/empathy-auth-client.c
433b24
@@ -22,7 +22,6 @@
433b24
 #include "config.h"
433b24
 
433b24
 #include <glib/gi18n.h>
433b24
-#include <gnutls/gnutls.h>
433b24
 
433b24
 #include "empathy-auth-factory.h"
433b24
 #include "empathy-bad-password-dialog.h"
433b24
@@ -297,7 +296,6 @@ main (int argc,
433b24
   g_option_context_free (context);
433b24
 
433b24
   empathy_gtk_init ();
433b24
-  gnutls_global_init ();
433b24
   g_set_application_name (_("Empathy authentication client"));
433b24
 
433b24
   /* Make empathy and empathy-auth-client appear as the same app in
433b24
diff --git a/tests/empathy-tls-test.c b/tests/empathy-tls-test.c
433b24
index b8f9ffcbb9af..9b62ae4e0ec7 100644
433b24
--- a/tests/empathy-tls-test.c
433b24
+++ b/tests/empathy-tls-test.c
433b24
@@ -1,6 +1,5 @@
433b24
 #include "config.h"
433b24
 
433b24
-#include <gnutls/gnutls.h>
433b24
 #include <telepathy-glib/telepathy-glib.h>
433b24
 #include <telepathy-glib/telepathy-glib-dbus.h>
433b24
 
433b24
@@ -744,7 +743,6 @@ main (int argc,
433b24
   int result;
433b24
 
433b24
   test_init (argc, argv);
433b24
-  gnutls_global_init ();
433b24
 
433b24
   g_test_add ("/tls/certificate_basics", Test, NULL,
433b24
           setup, test_certificate_mock_basics, teardown);
433b24
-- 
433b24
2.14.4
433b24