diff options
-rw-r--r-- | smime/ChangeLog | 27 | ||||
-rw-r--r-- | smime/gui/Makefile.am | 2 | ||||
-rw-r--r-- | smime/gui/ca-trust-dialog.c | 39 | ||||
-rw-r--r-- | smime/gui/cert-trust-dialog.c | 153 | ||||
-rw-r--r-- | smime/gui/cert-trust-dialog.h | 32 | ||||
-rw-r--r-- | smime/gui/certificate-manager.c | 39 | ||||
-rw-r--r-- | smime/gui/smime-ui.glade | 270 | ||||
-rw-r--r-- | smime/lib/e-cert.c | 52 | ||||
-rw-r--r-- | smime/lib/e-cert.h | 2 |
9 files changed, 508 insertions, 108 deletions
diff --git a/smime/ChangeLog b/smime/ChangeLog index d2f257ef17..b33478a713 100644 --- a/smime/ChangeLog +++ b/smime/ChangeLog @@ -1,3 +1,30 @@ +2004-05-28 Not Zed <NotZed@Ximian.com> + + ** See bugs #52061 & #52669. + + * gui/smime-ui.glade: added cert-trust-dialog and tweaked the + ca-trust-dialog. + + * gui/ca-trust-dialog.c (ca_trust_dialog_show): Fix the %s in the + label. Slack. + (ca_trust_dialog_show): slight rearrangement. + + * gui/certificate-manager.c (add_contact_cert): fill out fields. + + * lib/e-cert.c (e_cert_get_usage): helper to get the usage of a + cert. + + * gui/certificate-manager.c (edit_ca): use the right certdb, not + the e-one. + (add_user_cert): fill out missing columns. + + * lib/e-cert.c (e_cert_get_ca_cert): new method to find the ca + cert of a cert. + + * gui/cert-trust-dialog.[ch]: peer cert trust editor. + + * gui/certificate-manager.c (edit_contact): implement. + 2004-05-17 Jon Oberheide <jon@focalhost.com> * gui/e-cert-selector.c (e_cert_selector_new): add "Select diff --git a/smime/gui/Makefile.am b/smime/gui/Makefile.am index 3a18b30784..6a3dff3503 100644 --- a/smime/gui/Makefile.am +++ b/smime/gui/Makefile.am @@ -21,6 +21,8 @@ noinst_LTLIBRARIES = libevolution-smime.la libevolution_smime_la_SOURCES = \ ca-trust-dialog.c \ ca-trust-dialog.h \ + cert-trust-dialog.c \ + cert-trust-dialog.h \ certificate-manager.c \ certificate-manager.h \ certificate-viewer.c \ diff --git a/smime/gui/ca-trust-dialog.c b/smime/gui/ca-trust-dialog.c index b59e189b9e..b0dc07001e 100644 --- a/smime/gui/ca-trust-dialog.c +++ b/smime/gui/ca-trust-dialog.c @@ -41,13 +41,12 @@ typedef struct { GtkWidget *ssl_checkbutton; GtkWidget *email_checkbutton; GtkWidget *objsign_checkbutton; - GtkWidget *view_cert_button; ECert *cert; } CATrustDialogData; static void -free_data (gpointer data, GObject *where_the_object_was) +free_data (gpointer data) { CATrustDialogData *ctd = data; @@ -57,21 +56,26 @@ free_data (gpointer data, GObject *where_the_object_was) } static void -view_cert (GtkWidget *button, CATrustDialogData *data) +catd_response(GtkWidget *w, guint id, CATrustDialogData *data) { - GtkWidget *dialog = certificate_viewer_show (data->cert); - - gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data->dialog)); - - gtk_dialog_run (GTK_DIALOG (dialog)); - - gtk_widget_destroy (dialog); + switch (id) { + case GTK_RESPONSE_ACCEPT: { + GtkWidget *dialog = certificate_viewer_show (data->cert); + + g_signal_stop_emission_by_name(w, "response"); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data->dialog)); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + break; } + } } GtkWidget* ca_trust_dialog_show (ECert *cert, gboolean importing) { CATrustDialogData *ctd_data; + GtkWidget *w; + char *txt; ctd_data = g_new0 (CATrustDialogData, 1); ctd_data->gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, NULL, NULL); @@ -82,18 +86,15 @@ ca_trust_dialog_show (ECert *cert, gboolean importing) ctd_data->ssl_checkbutton = glade_xml_get_widget (ctd_data->gui, "ssl_trust_checkbutton"); ctd_data->email_checkbutton = glade_xml_get_widget (ctd_data->gui, "email_trust_checkbutton"); ctd_data->objsign_checkbutton = glade_xml_get_widget (ctd_data->gui, "objsign_trust_checkbutton"); - ctd_data->view_cert_button = glade_xml_get_widget (ctd_data->gui, "view_certificate_button"); - - g_signal_connect (ctd_data->view_cert_button, - "clicked", G_CALLBACK (view_cert), - ctd_data); - gtk_widget_realize (ctd_data->dialog); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (ctd_data->dialog)->action_area), 12); + w = glade_xml_get_widget(ctd_data->gui, "ca-trust-label"); + txt = g_strdup_printf(_("Certificate '%s' is a CA certificate.\n\nEdit trust settings:"), e_cert_get_cn(cert)); + gtk_label_set_text((GtkLabel *)w, txt); + g_free(txt); - g_object_weak_ref (G_OBJECT (ctd_data->dialog), free_data, ctd_data); + g_signal_connect (ctd_data->dialog, "response", G_CALLBACK (catd_response), ctd_data); - g_object_set_data (G_OBJECT (ctd_data->dialog), "CATrustDialogData", ctd_data); + g_object_set_data_full (G_OBJECT (ctd_data->dialog), "CATrustDialogData", ctd_data, free_data); return ctd_data->dialog; } diff --git a/smime/gui/cert-trust-dialog.c b/smime/gui/cert-trust-dialog.c new file mode 100644 index 0000000000..3148adfaa9 --- /dev/null +++ b/smime/gui/cert-trust-dialog.c @@ -0,0 +1,153 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: Chris Toshok <toshok@ximian.com> + * Michael Zucchi <notzed@ximian.com> + * + * Copyright (C) 2004 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "e-cert.h" +#include "e-cert-trust.h" +#include "e-cert-db.h" +#include "cert-trust-dialog.h" +#include "ca-trust-dialog.h" + +#include <gtk/gtkwidget.h> +#include <gtk/gtkradiobutton.h> +#include <gtk/gtkdialog.h> +#include <gtk/gtklabel.h> + +#include <libgnome/gnome-i18n.h> +#include <glade/glade.h> + +#define GLADE_FILE_NAME "smime-ui.glade" + +typedef struct { + GladeXML *gui; + GtkWidget *dialog; + GtkWidget *trust_button; + GtkWidget *notrust_button; + GtkWidget *label; + + ECert *cert, *cacert; +} CertTrustDialogData; + +static void +free_data (void *data) +{ + CertTrustDialogData *ctd = data; + + g_object_unref (ctd->cert); + g_object_unref (ctd->cacert); + g_object_unref (ctd->gui); + g_free (ctd); +} + +static void +ctd_response(GtkWidget *w, guint id, CertTrustDialogData *data) +{ + CERTCertTrust trust; + CERTCertificate *icert; + + switch (id) { + case GTK_RESPONSE_OK: + icert = e_cert_get_internal_cert(data->cert); + e_cert_trust_init(&trust); + e_cert_trust_set_valid_peer(&trust); + e_cert_trust_add_peer_trust (&trust, FALSE, + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (data->trust_button)), + FALSE); + CERT_ChangeCertTrust (CERT_GetDefaultCertDB(), icert, &trust); + break; + case GTK_RESPONSE_ACCEPT: { + g_signal_stop_emission_by_name(w, "response"); + + /* just *what on earth* was chris thinking here!?!?! copied from certificate-manager.c */ + GtkWidget *dialog = ca_trust_dialog_show (data->cacert, FALSE); + CERTCertificate *icert = e_cert_get_internal_cert (data->cacert); + + ca_trust_dialog_set_trust (dialog, + e_cert_trust_has_trusted_ca (icert->trust, TRUE, FALSE, FALSE), + e_cert_trust_has_trusted_ca (icert->trust, FALSE, TRUE, FALSE), + e_cert_trust_has_trusted_ca (icert->trust, FALSE, FALSE, TRUE)); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) { + gboolean trust_ssl, trust_email, trust_objsign; + + ca_trust_dialog_get_trust (dialog, + &trust_ssl, &trust_email, &trust_objsign); + + e_cert_trust_init (&trust); + e_cert_trust_set_valid_ca (&trust); + e_cert_trust_add_ca_trust (&trust, + trust_ssl, + trust_email, + trust_objsign); + + CERT_ChangeCertTrust(CERT_GetDefaultCertDB(), icert, &trust); + } + + gtk_widget_destroy (dialog); + break; } + } +} + +GtkWidget* +cert_trust_dialog_show (ECert *cert) +{ + CertTrustDialogData *ctd_data; + CERTCertificate *icert; + + ctd_data = g_new0 (CertTrustDialogData, 1); + ctd_data->gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, NULL, NULL); + + ctd_data->dialog = glade_xml_get_widget (ctd_data->gui, "cert-trust-dialog"); + ctd_data->cert = g_object_ref (cert); + ctd_data->cacert = e_cert_get_ca_cert(cert); + ctd_data->trust_button = glade_xml_get_widget(ctd_data->gui, "cert-trust"); + ctd_data->notrust_button = glade_xml_get_widget(ctd_data->gui, "cert-notrust"); + + ctd_data->label = glade_xml_get_widget(ctd_data->gui, "trust-label"); + + g_signal_connect(ctd_data->dialog, "response", G_CALLBACK(ctd_response), ctd_data); + + g_object_set_data_full (G_OBJECT (ctd_data->dialog), "CertTrustDialogData", ctd_data, free_data); + + icert = e_cert_get_internal_cert(cert); + if (e_cert_trust_has_trusted_peer(icert->trust, FALSE, TRUE, FALSE)) + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (ctd_data->trust_button), TRUE); + else + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (ctd_data->notrust_button), TRUE); + + + icert = e_cert_get_internal_cert(ctd_data->cacert); + if (e_cert_trust_has_trusted_ca(icert->trust, FALSE, TRUE, FALSE)) + gtk_label_set_text((GtkLabel *)ctd_data->label, + _("Because you trust the certificate authority that issued this certificate, " + "then you trust the authenticity of this certificate unless otherwise indicated here")); + else + gtk_label_set_text((GtkLabel *)ctd_data->label, + _("Because you do not trust the certificate authority that issued this certificate, " + "then you do not trust the authenticity of this certificate unless otherwise indicated here")); + + return ctd_data->dialog; +} diff --git a/smime/gui/cert-trust-dialog.h b/smime/gui/cert-trust-dialog.h new file mode 100644 index 0000000000..fe71c6a1b5 --- /dev/null +++ b/smime/gui/cert-trust-dialog.h @@ -0,0 +1,32 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: Chris Toshok <toshok@ximian.com> + * Michael Zucchi <notzed@ximian.com> + * + * Copyright (C) 2004 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + +#ifndef _CERT_TRUST_DIALOG_H_ +#define _CERT_TRUST_DIALOG_H + +struct _GtkWidget; +struct _ECert; + +struct _GtkWidget* cert_trust_dialog_show (struct _ECert *cert); + +#endif /* _CERT_TRUST_DIALOG_H_ */ diff --git a/smime/gui/certificate-manager.c b/smime/gui/certificate-manager.c index f291fffea4..81a392f463 100644 --- a/smime/gui/certificate-manager.c +++ b/smime/gui/certificate-manager.c @@ -34,10 +34,12 @@ #include <glade/glade.h> #include "evolution-config-control.h" #include "ca-trust-dialog.h" +#include "cert-trust-dialog.h" #include "certificate-manager.h" #include "certificate-viewer.h" #include "e-cert.h" +#include "e-cert-trust.h" #include "e-cert-db.h" #include "nss.h" @@ -320,6 +322,30 @@ view_contact (GtkWidget *widget, CertificateManagerData *cfm) } static void +edit_contact (GtkWidget *widget, CertificateManagerData *cfm) +{ + GtkTreeIter iter; + + if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW(cfm->contactcerts_treeview)), + NULL, + &iter)) { + ECert *cert; + + gtk_tree_model_get (GTK_TREE_MODEL (cfm->contactcerts_streemodel), + &iter, + 3, &cert, + -1); + + if (cert) { + GtkWidget *dialog = cert_trust_dialog_show (cert); + g_signal_connect (dialog, "response", + G_CALLBACK (gtk_widget_destroy), NULL); + gtk_widget_show (dialog); + } + } +} + +static void import_contact (GtkWidget *widget, CertificateManagerData *cfm) { GtkWidget *filesel = gtk_file_selection_new (_("Select a cert to import...")); @@ -438,6 +464,9 @@ initialize_contactcerts_ui (CertificateManagerData *cfm) if (cfm->view_contact_button) g_signal_connect (cfm->view_contact_button, "clicked", G_CALLBACK (view_contact), cfm); + if (cfm->edit_contact_button) + g_signal_connect (cfm->edit_contact_button, "clicked", G_CALLBACK (edit_contact), cfm); + if (cfm->import_contact_button) g_signal_connect (cfm->import_contact_button, "clicked", G_CALLBACK (import_contact), cfm); @@ -508,7 +537,7 @@ edit_ca (GtkWidget *widget, CertificateManagerData *cfm) trust_email, trust_objsign); - CERT_ChangeCertTrust (e_cert_db_peek (), icert, &trust); + CERT_ChangeCertTrust (CERT_GetDefaultCertDB(), icert, &trust); } gtk_widget_destroy (dialog); @@ -654,11 +683,17 @@ add_user_cert (CertificateManagerData *cfm, ECert *cert) if (e_cert_get_cn (cert)) gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 0, e_cert_get_cn (cert), + 1, e_cert_get_usage(cert), + 2, e_cert_get_serial_number(cert), + 3, e_cert_get_expires_on(cert), 4, cert, -1); else gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 0, e_cert_get_nickname (cert), + 1, e_cert_get_usage(cert), + 2, e_cert_get_serial_number(cert), + 3, e_cert_get_expires_on(cert), 4, cert, -1); } @@ -693,12 +728,14 @@ add_contact_cert (CertificateManagerData *cfm, ECert *cert) gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 0, e_cert_get_cn (cert), 1, e_cert_get_email (cert), + 2, e_cert_get_usage(cert), 3, cert, -1); else gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 0, e_cert_get_nickname (cert), 1, e_cert_get_email (cert), + 2, e_cert_get_usage(cert), 3, cert, -1); } diff --git a/smime/gui/smime-ui.glade b/smime/gui/smime-ui.glade index 5682522b8d..cda60ed349 100644 --- a/smime/gui/smime-ui.glade +++ b/smime/gui/smime-ui.glade @@ -1782,7 +1782,19 @@ <property name="layout_style">GTK_BUTTONBOX_END</property> <child> - <widget class="GtkButton" id="cancelbutton1"> + <widget class="GtkButton" id="view_certificate_button"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_View Certificate</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="response_id">-3</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="cancelbutton"> <property name="visible">True</property> <property name="can_default">True</property> <property name="can_focus">True</property> @@ -1794,7 +1806,7 @@ </child> <child> - <widget class="GtkButton" id="okbutton1"> + <widget class="GtkButton" id="okbutton"> <property name="visible">True</property> <property name="can_default">True</property> <property name="can_focus">True</property> @@ -1814,54 +1826,34 @@ </child> <child> - <widget class="GtkLabel" id="label64"> - <property name="visible">True</property> - <property name="label" translatable="yes">You have been asked to trust a new Certificate Authority (CA).</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label65"> - <property name="visible">True</property> - <property name="label" translatable="yes">Do you want to trust "%s" for the following purposes?</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox7"> + <widget class="GtkVBox" id="vbox9"> + <property name="border_width">12</property> <property name="visible">True</property> <property name="homogeneous">False</property> <property name="spacing">0</property> <child> + <widget class="GtkLabel" id="ca-trust-label"> + <property name="visible">True</property> + <property name="label" translatable="yes"></property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> <widget class="GtkCheckButton" id="ssl_trust_checkbutton"> <property name="visible">True</property> <property name="can_focus">True</property> @@ -1914,57 +1906,32 @@ <property name="fill">False</property> </packing> </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label66"> - <property name="visible">True</property> - <property name="label" translatable="yes">Before trusting this CA for any purpose, you should examine its certificate and its policy and procedures (if available).</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkAlignment" id="alignment5"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xscale">0</property> - <property name="yscale">1</property> <child> - <widget class="GtkButton" id="view_certificate_button"> + <widget class="GtkLabel" id="label66"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">View Certificate</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="label" translatable="yes">Before trusting this CA for any purpose, you should examine its certificate and its policy and procedures (if available).</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> </child> </widget> <packing> <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> + <property name="expand">True</property> + <property name="fill">True</property> </packing> </child> </widget> @@ -2099,4 +2066,131 @@ </child> </widget> +<widget class="GtkDialog" id="cert-trust-dialog"> + <property name="title" translatable="yes">Email Certificate Trust Settings</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="has_separator">False</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox3"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area3"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="editca"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Edit CA Trust</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="response_id">-3</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="editok"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-ok</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="response_id">-5</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox8"> + <property name="border_width">12</property> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="trust-label"> + <property name="visible">True</property> + <property name="label" translatable="yes"></property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkRadioButton" id="cert-trust"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Trust the authenticity of this certificate</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkRadioButton" id="cert-notrust"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Do not trust the authenticity of this certificate</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <property name="group">cert-trust</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + </glade-interface> diff --git a/smime/lib/e-cert.c b/smime/lib/e-cert.c index e6fbd57e76..d5a5f2b6e1 100644 --- a/smime/lib/e-cert.c +++ b/smime/lib/e-cert.c @@ -92,6 +92,8 @@ struct _ECertPrivate { char *serial_number; + char *usage_string; + char *sha1_fingerprint; char *md5_fingerprint; @@ -132,6 +134,8 @@ e_cert_dispose (GObject *object) if (ec->priv->serial_number) PORT_Free (ec->priv->serial_number); + g_free(ec->priv->usage_string); + if (ec->priv->sha1_fingerprint) PORT_Free (ec->priv->sha1_fingerprint); if (ec->priv->md5_fingerprint) @@ -412,6 +416,38 @@ e_cert_get_expires_on (ECert *cert) return cert->priv->expires_on_string; } +static struct { + int bit; + const char *text; +} usageinfo[] = { + /* x509 certificate usage types */ + { certificateUsageEmailSigner, N_("Sign") }, + { certificateUsageEmailRecipient, N_("Encrypt") }, +}; + +const char* +e_cert_get_usage(ECert *cert) +{ + if (cert->priv->usage_string == NULL) { + int i; + GString *str = g_string_new(""); + CERTCertificate *icert = e_cert_get_internal_cert (cert); + + for (i=0;i<sizeof(usageinfo)/sizeof(usageinfo[0]);i++) { + if (icert->keyUsage & usageinfo[i].bit) { + if (str->len != 0) + g_string_append(str, ", "); + g_string_append(str, _(usageinfo[i].text)); + } + } + + cert->priv->usage_string = str->str; + g_string_free(str, FALSE); + } + + return cert->priv->usage_string; +} + const char* e_cert_get_serial_number (ECert *cert) { @@ -455,6 +491,22 @@ e_cert_get_chain (ECert *ecert) return l; } +ECert * +e_cert_get_ca_cert(ECert *ecert) +{ + CERTCertificate *cert, *next = e_cert_get_internal_cert(ecert); + + do { + cert = next; + next = CERT_FindCertIssuer (cert, PR_Now(), certUsageAnyCA); + } while (next && next != cert); + + if (cert == e_cert_get_internal_cert(ecert)) + return g_object_ref(ecert); + else + return e_cert_new(cert); +} + static gboolean get_int_value (SECItem *versionItem, unsigned long *version) diff --git a/smime/lib/e-cert.h b/smime/lib/e-cert.h index 243ce1539b..5e0ae78fba 100644 --- a/smime/lib/e-cert.h +++ b/smime/lib/e-cert.h @@ -88,12 +88,14 @@ PRTime e_cert_get_issued_on_time (ECert *cert); const char* e_cert_get_issued_on (ECert *cert); PRTime e_cert_get_expires_on_time (ECert *cert); const char* e_cert_get_expires_on (ECert *cert); +const char* e_cert_get_usage(ECert *cert); const char* e_cert_get_serial_number (ECert *cert); const char* e_cert_get_sha1_fingerprint (ECert *cert); const char* e_cert_get_md5_fingerprint (ECert *cert); GList* e_cert_get_chain (ECert *cert); +ECert * e_cert_get_ca_cert (ECert *ecert); EASN1Object* e_cert_get_asn1_struct (ECert *cert); gboolean e_cert_mark_for_deletion (ECert *cert); |