diff libpurple/plugins/ssl/ssl-gnutls.c @ 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 fcca10d0ac7d
children daa68185a018
line wrap: on
line diff
--- 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 =