changeset 18962:fcd05c39803e

- Add purple_certificate_get_subject_name and associated libpurple machinery
author William Ehlhardt <williamehlhardt@gmail.com>
date Wed, 27 Jun 2007 03:39:19 +0000
parents fa138dbacff5
children 146907cd3b07
files libpurple/certificate.c libpurple/certificate.h
diffstat 2 files changed, 43 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/certificate.c	Wed Jun 27 01:35:28 2007 +0000
+++ b/libpurple/certificate.c	Wed Jun 27 03:39:19 2007 +0000
@@ -141,6 +141,24 @@
 	return fpr;
 }
 
+gchar *
+purple_certificate_get_subject_name(PurpleCertificate *crt)
+{
+	PurpleCertificateScheme *scheme;
+	gchar *subject_name;
+
+	g_return_val_if_fail(crt, NULL);
+	g_return_val_if_fail(crt->scheme, NULL);
+
+	scheme = crt->scheme;
+
+	g_return_val_if_fail(scheme->get_subject_name, NULL);
+
+	subject_name = (scheme->get_subject_name)(crt);
+
+	return subject_name;
+}
+
 /****************************************************************************/
 /* Builtin Verifiers, Pools, etc.                                           */
 /****************************************************************************/
--- a/libpurple/certificate.h	Wed Jun 27 01:35:28 2007 +0000
+++ b/libpurple/certificate.h	Wed Jun 27 03:39:19 2007 +0000
@@ -151,7 +151,18 @@
 	 */
 	gchar * (* get_issuer_unique_id)(PurpleCertificate *crt);
 
-	
+	/**
+	 * Gets the certificate subject's name
+	 *
+	 * For X.509, this is the "Common Name" field, as we're only using it
+	 * for hostname verification at the moment
+	 *
+	 * @see purple_certificate_get_subject_name()
+	 *
+	 * @param crt   Certificate instance
+	 * @return Newly allocated string with the certificate subject.
+	 */
+	gchar * (* get_subject_name)(PurpleCertificate *crt);
 	/* TODO: Fill out this structure */
 };
 
@@ -306,6 +317,19 @@
 GByteArray *
 purple_certificate_get_fingerprint_sha1(PurpleCertificate *crt);
 
+
+/**
+ * Gets the certificate subject's name
+ *
+ * For X.509, this is the "Common Name" field, as we're only using it
+ * for hostname verification at the moment
+ *
+ * @param crt   Certificate instance
+ * @return Newly allocated string with the certificate subject.
+ */
+gchar *
+purple_certificate_get_subject_name(PurpleCertificate *crt);
+
 /*@}*/
 
 /*****************************************************************************/