Mercurial > pidgin.yaz
changeset 19067:6c0aad79c4c5
- 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
author | William Ehlhardt <williamehlhardt@gmail.com> |
---|---|
date | Fri, 03 Aug 2007 06:12:42 +0000 |
parents | b631b409a515 |
children | 9ac0fbb569a5 |
files | libpurple/certificate.c libpurple/certificate.h libpurple/plugins/ssl/ssl-gnutls.c |
diffstat | 3 files changed, 23 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- 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); }
--- 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 */ };
--- 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 =