# HG changeset patch # User William Ehlhardt # Date 1186121562 0 # Node ID 6c0aad79c4c5b8e66e814b8b7e191a2eb1168160 # Parent b631b409a51564060f447f01ad048aff86e84976 - Change the internal structure of activation/expiration times to match the "NSS way", which is already how the libpurple public interface works - Change ssl-gnutls to match the above diff -r b631b409a515 -r 6c0aad79c4c5 libpurple/certificate.c --- a/libpurple/certificate.c Wed Aug 01 07:39:38 2007 +0000 +++ b/libpurple/certificate.c Fri Aug 03 06:12:42 2007 +0000 @@ -244,17 +244,8 @@ this? */ g_return_val_if_fail( (activation != NULL) || (expiration != NULL), FALSE); - /* Fulfill the caller's requests, if possible */ - if (activation) { - g_return_val_if_fail(scheme->get_activation, FALSE); - *activation = scheme->get_activation(crt); - } - if (expiration) { - g_return_val_if_fail(scheme->get_expiration, FALSE); - *expiration = scheme->get_expiration(crt); - } - - return TRUE; + /* Throw the request on down to the certscheme */ + return (scheme->get_times)(crt, activation, expiration); } diff -r b631b409a515 -r 6c0aad79c4c5 libpurple/certificate.h --- a/libpurple/certificate.h Wed Aug 01 07:39:38 2007 +0000 +++ b/libpurple/certificate.h Fri Aug 03 06:12:42 2007 +0000 @@ -235,10 +235,8 @@ */ gboolean (* check_subject_name)(PurpleCertificate *crt, const gchar *name); - /** Retrieve the certificate activation time */ - time_t (* get_activation)(PurpleCertificate *crt); - /** Retrieve the expiration time */ - time_t (* get_expiration)(PurpleCertificate *crt); + /** Retrieve the certificate activation/expiration times */ + gboolean (* get_times)(PurpleCertificate *crt, time_t *activation, time_t *expiration); /* TODO: Fill out this structure */ }; diff -r b631b409a515 -r 6c0aad79c4c5 libpurple/plugins/ssl/ssl-gnutls.c --- a/libpurple/plugins/ssl/ssl-gnutls.c Wed Aug 01 07:39:38 2007 +0000 +++ b/libpurple/plugins/ssl/ssl-gnutls.c Fri Aug 03 06:12:42 2007 +0000 @@ -782,32 +782,31 @@ } } -static time_t -x509_activation (PurpleCertificate *crt) +static gboolean +x509_times (PurpleCertificate *crt, time_t *activation, time_t *expiration) { gnutls_x509_crt_t crt_dat; + /* GnuTLS time functions return this on error */ + const time_t errval = (time_t) (-1); - g_assert(crt); - g_assert(crt->scheme == &x509_gnutls); + + g_return_val_if_fail(crt, FALSE); + g_return_val_if_fail(crt->scheme == &x509_gnutls, FALSE); crt_dat = X509_GET_GNUTLS_DATA(crt); - /* TODO: Errorcheck this? */ - return gnutls_x509_crt_get_activation_time(crt_dat); -} + if (activation) { + *activation = gnutls_x509_crt_get_activation_time(crt_dat); + } + if (expiration) { + *expiration = gnutls_x509_crt_get_expiration_time(crt_dat); + } -static time_t -x509_expiration (PurpleCertificate *crt) -{ - gnutls_x509_crt_t crt_dat; - - g_assert(crt); - g_assert(crt->scheme == &x509_gnutls); - - crt_dat = X509_GET_GNUTLS_DATA(crt); - - /* TODO: Errorcheck this? */ - return gnutls_x509_crt_get_expiration_time(crt_dat); + if (*activation == errval || *expiration == errval) { + return FALSE; + } + + return TRUE; } /* X.509 certificate operations provided by this plugin */ @@ -824,8 +823,7 @@ NULL, /* Issuer Unique ID */ x509_common_name, /* Subject name */ x509_check_name, /* Check subject name */ - x509_activation, /* Activation time */ - x509_expiration /* Expiration time */ + x509_times /* Activation/Expiration time */ }; static PurpleSslOps ssl_ops =