pidgin/pidgin

89bda8c0750d
Parents 5c9a99b257c0
Children d8633f765a9e
Copy changes from datallah's 2948449ffd12 from the
release-2.x.y branch to default.

I dropped these changes when I merged that branch into default because
the code had moved and it didn't seem appropriate to re-do the change
in the merge commit.

The only remaining change from that commit is to add a "View Issuer
Certificate" button to the accept dialog. I think it's a good idea to
give users a way to view info about the cert chain, but I'm not going
to spend the time to figure out how to do it in default. If anyone else
wants to, feel free.

If anyone is keeping a list of starter tasks for aspiring patch writers,
this is a great one.

Also, why the hell is the x509_display_string() function in the
library-specific code? The function is duplicated and almost 100% identical
in ssl-gnutls.c and ssl-nss.c. Ugh.

Refs #7034
https://developer.pidgin.im/ticket/7034
--- a/libpurple/plugins/ssl/ssl-gnutls.c Mon Jul 07 23:21:53 2014 -0700
+++ b/libpurple/plugins/ssl/ssl-gnutls.c Mon Jul 07 23:45:17 2014 -0700
@@ -1232,9 +1232,10 @@
{
gchar *sha_asc;
GByteArray *sha_bin;
- gchar *cn;
+ gchar *cn, *issuer_id;
gint64 activation, expiration;
gchar *activ_str, *expir_str;
+ gboolean self_signed;
gchar *text;
#if GLIB_CHECK_VERSION(2,26,0)
GDateTime *act_dt, *exp_dt;
@@ -1249,6 +1250,8 @@
/* TODO: Will break on CA certs */
cn = x509_common_name(crt);
+ issuer_id = purple_certificate_get_issuer_unique_id(crt);
+
/* Get the certificate times */
/* TODO: Check the times against localtime */
/* TODO: errorcheck? */
@@ -1271,19 +1274,24 @@
expir_str = g_strdup(ctime(&expiration));
#endif
+ self_signed = purple_certificate_signed_by(crt, crt);
+
/* Make messages */
text = g_strdup_printf(
_("Common name: %s\n\n"
+ "Issued by: %s\n\n"
"Fingerprint (SHA1): %s\n\n"
"Activation date: %s\n"
"Expiration date: %s\n"),
cn ? cn : "(null)",
+ self_signed ? _("(self-signed)") : (issuer_id ? issuer_id : "(null)"),
sha_asc ? sha_asc : "(null)",
activ_str ? activ_str : "(null)",
expir_str ? expir_str : "(null)");
/* Cleanup */
g_free(cn);
+ g_free(issuer_id);
g_free(sha_asc);
g_free(activ_str);
g_free(expir_str);
--- a/libpurple/plugins/ssl/ssl-nss.c Mon Jul 07 23:21:53 2014 -0700
+++ b/libpurple/plugins/ssl/ssl-nss.c Mon Jul 07 23:45:17 2014 -0700
@@ -951,9 +951,10 @@
{
gchar *sha_asc;
GByteArray *sha_bin;
- gchar *cn;
+ gchar *cn, *issuer_id;
gint64 activation, expiration;
gchar *activ_str, *expir_str;
+ gboolean self_signed;
gchar *text;
#if GLIB_CHECK_VERSION(2,26,0)
GDateTime *act_dt, *exp_dt;
@@ -967,6 +968,8 @@
/* TODO: Will break on CA certs */
cn = x509_common_name(crt);
+ issuer_id = purple_certificate_get_issuer_unique_id(crt);
+
/* Get the certificate times */
/* TODO: Check the times against localtime */
/* TODO: errorcheck? */
@@ -975,6 +978,7 @@
"Failed to get certificate times!\n");
activation = expiration = 0;
}
+
#if GLIB_CHECK_VERSION(2,26,0)
act_dt = g_date_time_new_from_unix_local(activation);
activ_str = g_date_time_format(act_dt, "%c");
@@ -988,19 +992,24 @@
expir_str = g_strdup(ctime(&expiration));
#endif
+ self_signed = purple_certificate_signed_by(crt, crt);
+
/* Make messages */
text = g_strdup_printf(
_("Common name: %s\n\n"
+ "Issued by: %s\n\n"
"Fingerprint (SHA1): %s\n\n"
"Activation date: %s\n"
"Expiration date: %s\n"),
cn ? cn : "(null)",
+ self_signed ? _("(self-signed)") : (issuer_id ? issuer_id : "(null)"),
sha_asc ? sha_asc : "(null)",
activ_str ? activ_str : "(null)",
expir_str ? expir_str : "(null)");
/* Cleanup */
g_free(cn);
+ g_free(issuer_id);
g_free(sha_asc);
g_free(activ_str);
g_free(expir_str);