diff options
author | Not Zed <NotZed@Ximian.com> | 2004-05-28 15:52:37 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-05-28 15:52:37 +0800 |
commit | 1dc76861d81c012c80871738ae6d18ed4fc881fe (patch) | |
tree | 0370aa975a8c377549f53d9bb99fc6b6d1fbcc70 /smime/lib/e-cert.c | |
parent | 80b2ded553a96ab787d327a928d4db11fb0264b2 (diff) | |
download | gsoc2013-evolution-1dc76861d81c012c80871738ae6d18ed4fc881fe.tar.gz gsoc2013-evolution-1dc76861d81c012c80871738ae6d18ed4fc881fe.tar.zst gsoc2013-evolution-1dc76861d81c012c80871738ae6d18ed4fc881fe.zip |
** See bugs #52061 & #52669.
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.
svn path=/trunk/; revision=26119
Diffstat (limited to 'smime/lib/e-cert.c')
-rw-r--r-- | smime/lib/e-cert.c | 52 |
1 files changed, 52 insertions, 0 deletions
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) |