[evolution-data-server] trust-prompt: Show a GcrCertificateWidget in the dialog.



commit 4266aa1c02de801979193c3ba705513079e92706
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Sep 22 17:49:05 2013 -0400

    trust-prompt: Show a GcrCertificateWidget in the dialog.
    
    Replaces the ugly CertificateViewer widget.

 configure.ac                               |   11 +
 libedataserver/e-source-webdav.c           |   37 --
 modules/trust-prompt/Makefile.am           |   10 +-
 modules/trust-prompt/certificate-viewer.c  |  691 --------------------
 modules/trust-prompt/certificate-viewer.h  |   32 -
 modules/trust-prompt/e-asn1-object.c       |  969 ----------------------------
 modules/trust-prompt/e-asn1-object.h       |  109 ----
 modules/trust-prompt/module-trust-prompt.c |  297 +++------
 modules/trust-prompt/trust-prompt-gtk.c    |   99 +--
 modules/trust-prompt/trust-prompt.h        |   11 +-
 10 files changed, 151 insertions(+), 2115 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3494a66..f3a8c5a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -443,6 +443,17 @@ if test "x$enable_gtk" = xyes; then
 
        ])])
 
+       PKG_CHECK_MODULES(
+               [GCR], [gcr-3 >= gcr_minimum_version],,
+               [AC_MSG_ERROR([
+
+       gcr-3.0 not found (or version < gcr_minimum_version)
+
+       If you want to disable gcr-3.0's GTK+ widgets,
+       please append --disable-gtk to configure.
+
+       ])])
+
        AC_DEFINE(HAVE_GTK, 1, [Define to 1 if you have the gtk+-3.0 package.])
 fi
 AM_CONDITIONAL(HAVE_GTK, [test x$enable_gtk = xyes])
diff --git a/libedataserver/e-source-webdav.c b/libedataserver/e-source-webdav.c
index c7e7f4f..8b101ce 100644
--- a/libedataserver/e-source-webdav.c
+++ b/libedataserver/e-source-webdav.c
@@ -1463,7 +1463,6 @@ e_source_webdav_prepare_ssl_trust_prompt_with_parent (ESourceWebdav *extension,
        gchar *old_hash = NULL;
        gchar *cert_errs_str;
        gchar *markup = NULL;
-       gint issuer_count;
 
        g_return_val_if_fail (
                E_IS_SOURCE_WEBDAV (extension),
@@ -1599,42 +1598,6 @@ e_source_webdav_prepare_ssl_trust_prompt_with_parent (ESourceWebdav *extension,
        g_free (cert_errs_str);
        g_free (markup);
 
-       issuer_count = 0;
-       while (cert) {
-               GTlsCertificate *issuer = NULL;
-               g_object_get (cert, "issuer", &issuer, NULL);
-
-               cert = issuer;
-
-               if (cert) {
-                       bytes = NULL;
-                       g_object_get (cert, "certificate", &bytes, NULL);
-
-                       if (bytes) {
-                               base64 = g_base64_encode (bytes->data, bytes->len);
-                               if (issuer_count == 0) {
-                                       e_named_parameters_set (
-                                       parameters, "issuer", base64);
-                               } else {
-                                       gchar *name;
-
-                                       name = g_strdup_printf (
-                                               "issuer-%d", issuer_count);
-                                       e_named_parameters_set (
-                                               parameters, name, base64);
-                                       g_free (name);
-                               }
-
-                               g_free (base64);
-                               g_byte_array_unref (bytes);
-                       } else {
-                               break;
-                       }
-               }
-
-               issuer_count++;
-       }
-
        return E_TRUST_PROMPT_RESPONSE_UNKNOWN;
 }
 
diff --git a/modules/trust-prompt/Makefile.am b/modules/trust-prompt/Makefile.am
index eedf305..cd5a149 100644
--- a/modules/trust-prompt/Makefile.am
+++ b/modules/trust-prompt/Makefile.am
@@ -1,10 +1,8 @@
 NULL =
 
-TRUST_PROMPT_SOURCES = trust-prompt-gtk.c \
-                         certificate-viewer.c \
-                         certificate-viewer.h
-TRUST_PROMPT_CFLAGS = $(GNOME_PLATFORM_CFLAGS) $(GTK_CFLAGS)
-TRUST_PROMPT_LIBS = $(GNOME_PLATFORM_LIBS) $(GTK_LIBS)
+TRUST_PROMPT_SOURCES = trust-prompt-gtk.c
+TRUST_PROMPT_CFLAGS = $(GNOME_PLATFORM_CFLAGS) $(GTK_CFLAGS) $(GCR_CFLAGS)
+TRUST_PROMPT_LIBS = $(GNOME_PLATFORM_LIBS) $(GTK_LIBS) $(GCR_LIBS)
 
 module_LTLIBRARIES = module-trust-prompt.la
 
@@ -19,8 +17,6 @@ module_trust_prompt_la_CPPFLAGS = \
        $(NULL)
 
 module_trust_prompt_la_SOURCES = \
-       e-asn1-object.c \
-       e-asn1-object.h \
        module-trust-prompt.c \
        trust-prompt.h \
        $(TRUST_PROMPT_SOURCES) \
diff --git a/modules/trust-prompt/module-trust-prompt.c b/modules/trust-prompt/module-trust-prompt.c
index 2a7bfe4..c77ac8c 100644
--- a/modules/trust-prompt/module-trust-prompt.c
+++ b/modules/trust-prompt/module-trust-prompt.c
@@ -22,8 +22,6 @@
 
 #include <glib/gi18n-lib.h>
 
-#include <cert.h>
-
 #include <libebackend/libebackend.h>
 #include "trust-prompt.h"
 
@@ -36,8 +34,6 @@ typedef struct _ETrustPromptClass ETrustPromptClass;
 
 struct _ETrustPrompt {
        EUserPrompterServerExtension parent;
-
-       gboolean nss_initialized;
 };
 
 struct _ETrustPromptClass {
@@ -51,90 +47,13 @@ void e_module_unload (GTypeModule *type_module);
 /* Forward Declarations */
 GType e_trust_prompt_get_type (void);
 
-G_DEFINE_DYNAMIC_TYPE (ETrustPrompt, e_trust_prompt, E_TYPE_USER_PROMPTER_SERVER_EXTENSION)
-
-static gboolean trust_prompt_show_trust_prompt (EUserPrompterServerExtension *extension,
-                                               gint prompt_id,
-                                               const ENamedParameters *parameters);
+G_DEFINE_DYNAMIC_TYPE (
+       ETrustPrompt,
+       e_trust_prompt,
+       E_TYPE_USER_PROMPTER_SERVER_EXTENSION)
 
 #define TRUST_PROMPT_DIALOG "ETrustPrompt::trust-prompt"
 
-static void
-trust_prompt_register_dialogs (EExtension *extension,
-                               EUserPrompterServer *server)
-{
-       ETrustPrompt *trust_prompt = E_TRUST_PROMPT (extension);
-
-       if (!trust_prompt->nss_initialized) {
-               trust_prompt->nss_initialized = TRUE;
-
-               /* Use camel_init() to initialise NSS consistently... */
-               camel_init (e_get_user_data_dir (), TRUE);
-       }
-
-       e_user_prompter_server_register (server, extension, TRUST_PROMPT_DIALOG);
-}
-
-static gboolean
-trust_prompt_prompt (EUserPrompterServerExtension *extension,
-                     gint prompt_id,
-                     const gchar *dialog_name,
-                     const ENamedParameters *parameters)
-{
-       if (g_strcmp0 (dialog_name, TRUST_PROMPT_DIALOG) == 0)
-               return trust_prompt_show_trust_prompt (extension, prompt_id, parameters);
-
-       return FALSE;
-}
-
-static void
-trust_prompt_finalize (GObject *object)
-{
-       ETrustPrompt *trust_prompt = E_TRUST_PROMPT (object);
-
-       if (trust_prompt->nss_initialized)
-               camel_shutdown ();
-
-       /* Chain up to parent's finalize() method. */
-       G_OBJECT_CLASS (e_trust_prompt_parent_class)->finalize (object);
-}
-
-static void
-e_trust_prompt_class_init (ETrustPromptClass *class)
-{
-       GObjectClass *object_class;
-       EUserPrompterServerExtensionClass *server_extension_class;
-
-       object_class = G_OBJECT_CLASS (class);
-       object_class->finalize = trust_prompt_finalize;
-
-       server_extension_class = E_USER_PROMPTER_SERVER_EXTENSION_CLASS (class);
-       server_extension_class->register_dialogs = trust_prompt_register_dialogs;
-       server_extension_class->prompt = trust_prompt_prompt;
-}
-
-static void
-e_trust_prompt_class_finalize (ETrustPromptClass *class)
-{
-}
-
-static void
-e_trust_prompt_init (ETrustPrompt *trust_prompt)
-{
-       trust_prompt->nss_initialized = FALSE;
-}
-
-G_MODULE_EXPORT void
-e_module_load (GTypeModule *type_module)
-{
-       e_trust_prompt_register_type (type_module);
-}
-
-G_MODULE_EXPORT void
-e_module_unload (GTypeModule *type_module)
-{
-}
-
 /* dialog definitions */
 
 /* ETrustPrompt::trust-prompt
@@ -144,12 +63,6 @@ e_module_unload (GTypeModule *type_module)
  *    "certificate" - a base64-encoded DER certificate, for which ask on trust
  *    "certificate-errors" - a hexa-decimal integer (as string) corresponding to GTlsCertificateFlags
  *
- * It can contain, optionally, chain of issuers:
- *    "issuer"   - a base64-encoded DER certificate, issuer of "certificate"
- *    "issuer-1" - a base64-encoded DER certificate, issuer of "issuer"
- *    "issuer-2" - a base64-encoded DER certificate, issuer of "issuer-1"
- *    and so on
- *
  * Result of the dialog is:
  *    0 - reject
  *    1 - accept permanently
@@ -160,37 +73,6 @@ e_module_unload (GTypeModule *type_module)
  */
 
 static gchar *
-cert_fingerprint (CERTCertificate *cert)
-{
-       GChecksum *checksum;
-       guint8 *digest;
-       gsize length;
-       guchar fingerprint[50], *f;
-       gint i;
-       const gchar tohex[16] = "0123456789abcdef";
-
-       length = g_checksum_type_get_length (G_CHECKSUM_MD5);
-       digest = g_alloca (length);
-
-       checksum = g_checksum_new (G_CHECKSUM_MD5);
-       g_checksum_update (checksum, cert->derCert.data, cert->derCert.len);
-       g_checksum_get_digest (checksum, digest, &length);
-       g_checksum_free (checksum);
-
-       for (i = 0,f = fingerprint; i < length; i++) {
-               guint c = digest[i];
-
-               *f++ = tohex[(c >> 4) & 0xf];
-               *f++ = tohex[c & 0xf];
-               *f++ = ':';
-       }
-
-       fingerprint[47] = 0;
-
-       return g_strdup ((gchar *) fingerprint);
-}
-
-static gchar *
 cert_errors_to_reason (GTlsCertificateFlags flags)
 {
        struct _convert_table {
@@ -227,60 +109,15 @@ cert_errors_to_reason (GTlsCertificateFlags flags)
 }
 
 static void
-trust_prompt_free_certificate (gpointer cert)
+parser_parsed_cb (GcrParser *parser,
+                  GcrParsed **out_parsed)
 {
-       if (!cert)
-               return;
+       GcrParsed *parsed;
 
-       CERT_DestroyCertificate (cert);
-}
+       parsed = gcr_parser_get_parsed (parser);
+       g_return_if_fail (parsed != NULL);
 
-static GSList *
-trust_prompt_get_issuers (CERTCertDBHandle *certdb,
-                          const ENamedParameters *parameters)
-{
-       GSList *issuers = NULL;
-       CERTCertificate *cert;
-       SECItem derCert;
-       gsize derCert_len = 0;
-       gint ii;
-
-       g_return_val_if_fail (certdb != NULL, NULL);
-       g_return_val_if_fail (parameters != NULL, NULL);
-
-       for (ii = 0; ii >= 0; ii++) {
-               const gchar *base64_cert;
-
-               if (ii == 0) {
-                       base64_cert = e_named_parameters_get (parameters, "issuer");
-               } else {
-                       gchar *key;
-
-                       key = g_strdup_printf ("issuer-%d", ii);
-                       base64_cert = e_named_parameters_get (parameters, key);
-                       g_free (key);
-               }
-
-               if (!base64_cert)
-                       break;
-
-               derCert.type = siDERCertBuffer;
-               derCert.data = g_base64_decode (base64_cert, &derCert_len);
-               if (!derCert.data)
-                       break;
-
-               derCert.len = derCert_len;
-
-               cert = CERT_NewTempCertificate (certdb, &derCert, NULL, PR_FALSE, PR_TRUE);
-               g_free (derCert.data);
-
-               if (!cert)
-                       break;
-
-               issuers = g_slist_prepend (issuers, cert);
-       }
-
-       return g_slist_reverse (issuers);
+       *out_parsed = gcr_parsed_ref (parsed);
 }
 
 static gboolean
@@ -289,18 +126,27 @@ trust_prompt_show_trust_prompt (EUserPrompterServerExtension *extension,
                                 const ENamedParameters *parameters)
 {
        const gchar *host, *markup, *base64_cert, *cert_errs_str;
-       gchar *fingerprint, *reason;
+       gchar *reason;
        gint64 cert_errs;
-       CERTCertDBHandle *certdb;
-       CERTCertificate *cert;
-       GSList *issuers;
-       SECItem derCert;
-       gsize derCert_len = 0;
+       GcrParser *parser;
+       GcrParsed *parsed = NULL;
+       guchar *data;
+       gsize data_length;
        gboolean success;
+       GError *local_error = NULL;
 
        g_return_val_if_fail (extension != NULL, FALSE);
        g_return_val_if_fail (parameters != NULL, FALSE);
 
+       /* Continue even if PKCS#11 module registration fails.
+        * Certificate details won't display correctly but the
+        * user can still respond to the prompt. */
+       gcr_pkcs11_initialize (NULL, &local_error);
+       if (local_error != NULL) {
+               g_warning ("%s: %s", G_STRFUNC, local_error->message);
+               g_clear_error (&local_error);
+       }
+
        host = e_named_parameters_get (parameters, "host");
        markup = e_named_parameters_get (parameters, "markup");
        base64_cert = e_named_parameters_get (parameters, "certificate");
@@ -310,28 +156,89 @@ trust_prompt_show_trust_prompt (EUserPrompterServerExtension *extension,
        g_return_val_if_fail (base64_cert != NULL, FALSE);
        g_return_val_if_fail (cert_errs_str != NULL, FALSE);
 
-       derCert.type = siDERCertBuffer;
-       derCert.data = g_base64_decode (base64_cert, &derCert_len);
-       g_return_val_if_fail (derCert.data != NULL, FALSE);
-       derCert.len = derCert_len;
+       cert_errs = g_ascii_strtoll (cert_errs_str, NULL, 16);
+       reason = cert_errors_to_reason (cert_errs);
 
-       certdb = CERT_GetDefaultCertDB ();
-       cert = CERT_NewTempCertificate (certdb, &derCert, NULL, PR_FALSE, PR_TRUE);
-       g_return_val_if_fail (cert != NULL, FALSE);
+       parser = gcr_parser_new ();
 
-       issuers = trust_prompt_get_issuers (certdb, parameters);
+       g_signal_connect (
+               parser, "parsed",
+               G_CALLBACK (parser_parsed_cb), &parsed);
 
-       cert_errs = g_ascii_strtoll (cert_errs_str, NULL, 16);
-       reason = cert_errors_to_reason (cert_errs);
-       fingerprint = cert_fingerprint (cert);
+       data = g_base64_decode (base64_cert, &data_length);
+       gcr_parser_parse_data (parser, data, data_length, &local_error);
+       g_free (data);
 
-       success = trust_prompt_show (extension, prompt_id, host, markup, cert, fingerprint, reason, issuers);
+       g_object_unref (parser);
+
+       /* Sanity check. */
+       g_warn_if_fail (
+               ((parsed != NULL) && (local_error == NULL)) ||
+               ((parsed == NULL) && (local_error != NULL)));
+
+       if (parsed != NULL) {
+               success = trust_prompt_show (
+                       extension, prompt_id, host, markup, parsed, reason);
+               gcr_parsed_unref (parsed);
+       }
+
+       if (local_error != NULL) {
+               g_warning ("%s: %s", G_STRFUNC, local_error->message);
+               g_clear_error (&local_error);
+               success = FALSE;
+       }
 
-       trust_prompt_free_certificate (cert);
-       g_slist_free_full (issuers, trust_prompt_free_certificate);
-       g_free (derCert.data);
-       g_free (fingerprint);
        g_free (reason);
 
        return success;
 }
+static void
+trust_prompt_register_dialogs (EExtension *extension,
+                               EUserPrompterServer *server)
+{
+       e_user_prompter_server_register (server, extension, TRUST_PROMPT_DIALOG);
+}
+
+static gboolean
+trust_prompt_prompt (EUserPrompterServerExtension *extension,
+                     gint prompt_id,
+                     const gchar *dialog_name,
+                     const ENamedParameters *parameters)
+{
+       if (g_strcmp0 (dialog_name, TRUST_PROMPT_DIALOG) == 0)
+               return trust_prompt_show_trust_prompt (extension, prompt_id, parameters);
+
+       return FALSE;
+}
+
+static void
+e_trust_prompt_class_init (ETrustPromptClass *class)
+{
+       EUserPrompterServerExtensionClass *server_extension_class;
+
+       server_extension_class = E_USER_PROMPTER_SERVER_EXTENSION_CLASS (class);
+       server_extension_class->register_dialogs = trust_prompt_register_dialogs;
+       server_extension_class->prompt = trust_prompt_prompt;
+}
+
+static void
+e_trust_prompt_class_finalize (ETrustPromptClass *class)
+{
+}
+
+static void
+e_trust_prompt_init (ETrustPrompt *trust_prompt)
+{
+}
+
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
+{
+       e_trust_prompt_register_type (type_module);
+}
+
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
+{
+}
+
diff --git a/modules/trust-prompt/trust-prompt-gtk.c b/modules/trust-prompt/trust-prompt-gtk.c
index 23d4f70..e7b3738 100644
--- a/modules/trust-prompt/trust-prompt-gtk.c
+++ b/modules/trust-prompt/trust-prompt-gtk.c
@@ -23,11 +23,9 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n-lib.h>
 
-#include <cert.h>
 #include <libebackend/libebackend.h>
 
 #include "trust-prompt.h"
-#include "certificate-viewer.h"
 
 static void
 trust_prompt_add_info_line (GtkGrid *grid,
@@ -76,27 +74,7 @@ trust_prompt_add_info_line (GtkGrid *grid,
        pango_attr_list_unref (bold);
 }
 
-static void
-trust_prompt_free_certificate (gpointer cert)
-{
-       if (!cert)
-               return;
-
-       CERT_DestroyCertificate (cert);
-}
-
-static void
-trust_prompt_free_issuers (gpointer issuers)
-{
-       if (!issuers)
-               return;
-
-       g_slist_free_full (issuers, trust_prompt_free_certificate);
-}
-
 #define TRUST_PROMP_ID_KEY     "ETrustPrompt::prompt-id-key"
-#define TRUST_PROMP_CERT_KEY   "ETrustPrompt::cert-key"
-#define TRUST_PROMP_ISSUERS_KEY        "ETrustPrompt::issuers-key"
 
 static void
 trust_prompt_response_cb (GtkWidget *dialog,
@@ -105,20 +83,6 @@ trust_prompt_response_cb (GtkWidget *dialog,
 {
        gint prompt_id;
 
-       if (response == GTK_RESPONSE_HELP) {
-               GtkWidget *viewer;
-
-               viewer = certificate_viewer_new (
-                       GTK_WINDOW (dialog),
-                       g_object_get_data (G_OBJECT (dialog), TRUST_PROMP_CERT_KEY),
-                       g_object_get_data (G_OBJECT (dialog), TRUST_PROMP_ISSUERS_KEY));
-
-               gtk_dialog_run (GTK_DIALOG (viewer));
-               gtk_widget_destroy (viewer);
-
-               return;
-       }
-
        prompt_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), TRUST_PROMP_ID_KEY));
        gtk_widget_destroy (dialog);
 
@@ -139,51 +103,46 @@ trust_prompt_show (EUserPrompterServerExtension *extension,
                    gint prompt_id,
                    const gchar *host,
                    const gchar *markup,
-                   const CERTCertificate *pcert,
-                   const gchar *cert_fingerprint,
-                   const gchar *reason,
-                   const GSList *pissuers)
+                   GcrParsed *parsed,
+                   const gchar *reason)
 {
+       GcrCertificateWidget *certificate_widget;
+       GcrCertificate *certificate;
+       GckAttributes *attributes;
        GtkWidget *dialog, *widget;
        GtkGrid *grid;
-       gchar *tmp, *issuer, *subject, *head;
-       GSList *issuers, *iter;
-       CERTCertificate *cert;
+       const guchar *data;
+       gsize length;
+       gchar *tmp;
        gint row = 0;
 
-       cert = CERT_DupCertificate ((CERTCertificate *) pcert);
-       issuers = g_slist_copy ((GSList *) pissuers);
-       for (iter = issuers; iter; iter = g_slist_next (iter)) {
-               if (iter->data)
-                       iter->data = CERT_DupCertificate (iter->data);
-       }
-
        dialog = gtk_dialog_new_with_buttons (
                _("Certificate trust..."), NULL, 0,
-               _("_View Certificate"), GTK_RESPONSE_HELP,
                _("_Reject"), GTK_RESPONSE_REJECT,
                _("Accept _Temporarily"), GTK_RESPONSE_YES,
                _("_Accept Permanently"), GTK_RESPONSE_ACCEPT,
                NULL);
 
+       widget = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
        gtk_window_set_icon_name (GTK_WINDOW (dialog), "evolution");
        gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
+       gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
 
        grid = g_object_new (
                GTK_TYPE_GRID,
                "orientation", GTK_ORIENTATION_HORIZONTAL,
                "row-homogeneous", FALSE,
-               "row-spacing", 2,
+               "row-spacing", 6,
                "column-homogeneous", FALSE,
-               "column-spacing", 6,
+               "column-spacing", 12,
                "hexpand", TRUE,
                "halign", GTK_ALIGN_FILL,
                "vexpand", TRUE,
                "valign", GTK_ALIGN_FILL,
-               "border-width", 12,
                NULL);
 
-       widget = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+       gtk_container_set_border_width (GTK_CONTAINER (grid), 5);
        gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (grid));
 
        widget = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_DIALOG);
@@ -191,7 +150,6 @@ trust_prompt_show (EUserPrompterServerExtension *extension,
                G_OBJECT (widget),
                "vexpand", FALSE,
                "valign", GTK_ALIGN_START,
-               "xpad", 6,
                NULL);
        gtk_grid_attach (grid, widget, 0, row, 1, 3);
 
@@ -206,31 +164,32 @@ trust_prompt_show (EUserPrompterServerExtension *extension,
                markup = tmp;
        }
 
-       head = g_strdup_printf ("%s\n\n%s", markup, _("Detailed information about the certificate:"));
-
        widget = gtk_label_new (NULL);
-       gtk_label_set_markup (GTK_LABEL (widget), head);
+       gtk_label_set_markup (GTK_LABEL (widget), markup);
        gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.0);
-       g_free (head);
+
        g_free (tmp);
 
        gtk_grid_attach (grid, widget, 1, row, 2, 1);
        row++;
 
-       issuer = CERT_NameToAscii (&cert->issuer);
-       subject = CERT_NameToAscii (&cert->subject);
-
-       trust_prompt_add_info_line (grid, _("Issuer:"), issuer, TRUE, &row);
-       trust_prompt_add_info_line (grid, _("Subject:"), subject, TRUE, &row);
-       trust_prompt_add_info_line (grid, _("Fingerprint:"), cert_fingerprint, TRUE, &row);
        trust_prompt_add_info_line (grid, _("Reason:"), reason, FALSE, &row);
 
-       PORT_Free (issuer);
-       PORT_Free (subject);
+       data = gcr_parsed_get_data (parsed, &length);
+       attributes = gcr_parsed_get_attributes (parsed);
+
+       certificate = gcr_simple_certificate_new (data, length);
+
+       certificate_widget = gcr_certificate_widget_new (certificate);
+       gcr_certificate_widget_set_attributes (certificate_widget, attributes);
+
+       widget = GTK_WIDGET (certificate_widget);
+       gtk_grid_attach (grid, widget, 1, row, 2, 1);
+       gtk_widget_show (widget);
+
+       g_clear_object (&certificate);
 
        g_object_set_data (G_OBJECT (dialog), TRUST_PROMP_ID_KEY, GINT_TO_POINTER (prompt_id));
-       g_object_set_data_full (G_OBJECT (dialog), TRUST_PROMP_CERT_KEY, cert, trust_prompt_free_certificate);
-       g_object_set_data_full (G_OBJECT (dialog), TRUST_PROMP_ISSUERS_KEY, issuers, 
trust_prompt_free_issuers);
 
        g_signal_connect (dialog, "response", G_CALLBACK (trust_prompt_response_cb), extension);
 
diff --git a/modules/trust-prompt/trust-prompt.h b/modules/trust-prompt/trust-prompt.h
index c80f62c..1778997 100644
--- a/modules/trust-prompt/trust-prompt.h
+++ b/modules/trust-prompt/trust-prompt.h
@@ -19,7 +19,10 @@
 #ifndef TRUST_PROMPT_H
 #define TRUST_PROMPT_H
 
-#include <cert.h>
+/* XXX Yeah, yeah... */
+#define GCR_API_SUBJECT_TO_CHANGE
+
+#include <gcr/gcr.h>
 #include <libebackend/libebackend.h>
 
 /* This shows a trust-prompt. The function may not block and returns whether
@@ -37,9 +40,7 @@ trust_prompt_show (EUserPrompterServerExtension *extension,
                   gint prompt_id,
                   const gchar *host,
                   const gchar *markup,
-                  const CERTCertificate *pcert,
-                  const gchar *cert_fingerprint,
-                  const gchar *reason,
-                  const GSList *pissuers);
+                  GcrParsed *parsed,
+                  const gchar *reason);
 
 #endif /* TRUST_PROMPT_H */


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