# HG changeset patch # User William Ehlhardt # Date 1186461061 0 # Node ID daa68185a01827783c8e0456d7cdf7048d91abaf # Parent a0138be8d725f9069899befd6660354ac587592d - Add purple_certificate_signed_by - Modify ssl-gnutls to expose its support for above diff -r a0138be8d725 -r daa68185a018 libpurple/certificate.c --- a/libpurple/certificate.c Tue Aug 07 04:06:48 2007 +0000 +++ b/libpurple/certificate.c Tue Aug 07 04:31:01 2007 +0000 @@ -151,6 +151,22 @@ g_list_free(crt_list); } +gboolean +purple_certificate_signed_by(PurpleCertificate *crt, PurpleCertificate *issuer) +{ + PurpleCertificateScheme *scheme; + + g_return_val_if_fail(crt, FALSE); + g_return_val_if_fail(issuer, FALSE); + + scheme = crt->scheme; + g_return_val_if_fail(scheme, FALSE); + /* We can't compare two certs of unrelated schemes, obviously */ + g_return_val_if_fail(issuer->scheme == scheme, FALSE); + + return (scheme->signed_by)(crt, issuer); +} + PurpleCertificate * purple_certificate_import(PurpleCertificateScheme *scheme, const gchar *filename) { diff -r a0138be8d725 -r daa68185a018 libpurple/certificate.h --- a/libpurple/certificate.h Tue Aug 07 04:06:48 2007 +0000 +++ b/libpurple/certificate.h Tue Aug 07 04:31:01 2007 +0000 @@ -188,6 +188,9 @@ */ void (* destroy_certificate)(PurpleCertificate * crt); + /** Find whether "crt" has a valid signature from issuer "issuer" + * @see purple_certificate_signed_by() */ + gboolean (*signed_by)(PurpleCertificate *crt, PurpleCertificate *issuer); /** * Retrieves the certificate public key fingerprint using SHA1 * @@ -408,6 +411,19 @@ purple_certificate_destroy_list (GList * crt_list); /** + * Check whether 'crt' has a valid signature made by 'issuer' + * + * @param crt Certificate instance to check signature of + * @param issuer Certificate thought to have signed 'crt' + * + * @return TRUE if 'crt' has a valid signature made by 'issuer', + * otherwise FALSE + * @TODO Find a way to give the reason (bad signature, not the issuer, etc.) + */ +gboolean +purple_certificate_signed_by(PurpleCertificate *crt, PurpleCertificate *issuer); + +/** * Imports a PurpleCertificate from a file * * @param scheme Scheme to import under diff -r a0138be8d725 -r daa68185a018 libpurple/plugins/ssl/ssl-gnutls.c --- a/libpurple/plugins/ssl/ssl-gnutls.c Tue Aug 07 04:06:48 2007 +0000 +++ b/libpurple/plugins/ssl/ssl-gnutls.c Tue Aug 07 04:31:01 2007 +0000 @@ -818,6 +818,7 @@ x509_export_certificate, /* Certificate export function */ x509_copy_certificate, /* Copy */ x509_destroy_certificate, /* Destroy cert */ + x509_certificate_signed_by, /* Signature checker */ x509_sha1sum, /* SHA1 fingerprint */ NULL, /* Unique ID */ NULL, /* Issuer Unique ID */