summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2009-07-06 14:53:42 (GMT)
committerWill Thompson <will.thompson@collabora.co.uk>2009-07-06 14:55:35 (GMT)
commitedc5b33617f2b7c8dc523c18937b1349e4d265e7 (patch)
treee66d178434f1e5f647f057a1d2f69f831558d974
parenta0463cd71fbbdf253f1cdd6964e8698b55a62077 (diff)
downloadpidgin-edc5b33617f2b7c8dc523c18937b1349e4d265e7.tar.gz
pidgin-edc5b33617f2b7c8dc523c18937b1349e4d265e7.tar.xz
Allow associating cert. verification reqs with an account
-rw-r--r--libpurple/certificate.c43
-rw-r--r--libpurple/certificate.h8
2 files changed, 51 insertions, 0 deletions
diff --git a/libpurple/certificate.c b/libpurple/certificate.c
index 3e87d21..8cbdf2b 100644
--- a/libpurple/certificate.c
+++ b/libpurple/certificate.c
@@ -43,12 +43,38 @@ static GList *cert_verifiers = NULL;
/** List of registered Pools */
static GList *cert_pools = NULL;
+/* Maps outstanding PurpleCertificateVerificationRequest *s to their associated
+ * PurpleAccount *, if any. This is a workaround for being unable to extend
+ * PurpleCertificateVerificationRequest and should be removed when we break
+ * API.
+ */
+static GHashTable *cert_verification_request_accounts = NULL;
+
+static PurpleAccount *
+vrq_get_account (
+ PurpleCertificateVerificationRequest *vrq)
+{
+ return g_hash_table_lookup(cert_verification_request_accounts, vrq);
+}
+
void
purple_certificate_verify (PurpleCertificateVerifier *verifier,
const gchar *subject_name, GList *cert_chain,
PurpleCertificateVerifiedCallback cb,
gpointer cb_data)
{
+ purple_certificate_verify_for_account(verifier, NULL, subject_name,
+ cert_chain, cb, cb_data);
+}
+
+void
+purple_certificate_verify_for_account (PurpleCertificateVerifier *verifier,
+ PurpleAccount *account,
+ const gchar *subject_name,
+ GList *cert_chain,
+ PurpleCertificateVerifiedCallback cb,
+ gpointer cb_data)
+{
PurpleCertificateVerificationRequest *vrq;
PurpleCertificateScheme *scheme;
@@ -115,6 +141,8 @@ purple_certificate_verify_complete(PurpleCertificateVerificationRequest *vrq,
g_free(vrq->subject_name);
purple_certificate_destroy_list(vrq->cert_chain);
+ g_hash_table_remove(cert_verification_request_accounts, vrq);
+
/* A structure born
* to much ado
* and with so much within.
@@ -1553,6 +1581,8 @@ static PurpleCertificateVerifier x509_tls_cached = {
void
purple_certificate_init(void)
{
+ cert_verification_request_accounts = g_hash_table_new(NULL, NULL);
+
/* Register builtins */
purple_certificate_register_verifier(&x509_singleuse);
purple_certificate_register_pool(&x509_ca);
@@ -1563,11 +1593,24 @@ purple_certificate_init(void)
void
purple_certificate_uninit(void)
{
+ guint size;
+
/* Unregister all Verifiers */
g_list_foreach(cert_verifiers, (GFunc)purple_certificate_unregister_verifier, NULL);
/* Unregister all Pools */
g_list_foreach(cert_pools, (GFunc)purple_certificate_unregister_pool, NULL);
+
+ size = g_hash_table_size(cert_verification_request_accounts);
+
+ if (size > 0) {
+ purple_debug_warning("certificate",
+ "%d verification requests still pending",
+ size);
+ }
+
+ g_hash_table_destroy(cert_verification_request_accounts);
+ cert_verification_request_accounts = NULL;
}
gpointer
diff --git a/libpurple/certificate.h b/libpurple/certificate.h
index 5cfeb2c..7afb843 100644
--- a/libpurple/certificate.h
+++ b/libpurple/certificate.h
@@ -388,6 +388,14 @@ purple_certificate_verify (PurpleCertificateVerifier *verifier,
PurpleCertificateVerifiedCallback cb,
gpointer cb_data);
+void
+purple_certificate_verify_for_account (PurpleCertificateVerifier *verifier,
+ PurpleAccount *account,
+ const gchar *subject_name,
+ GList *cert_chain,
+ PurpleCertificateVerifiedCallback cb,
+ gpointer cb_data);
+
/**
* Completes and destroys a VerificationRequest
*