# HG changeset patch # User William Ehlhardt # Date 1182915559 0 # Node ID fcd05c39803e589a7539f4dceae0e41a108eeef7 # Parent fa138dbacff5f6faac323aba29d2df3368f3699b - Add purple_certificate_get_subject_name and associated libpurple machinery diff -r fa138dbacff5 -r fcd05c39803e libpurple/certificate.c --- 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. */ /****************************************************************************/ diff -r fa138dbacff5 -r fcd05c39803e libpurple/certificate.h --- 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); + /*@}*/ /*****************************************************************************/