summaryrefslogtreecommitdiff
path: root/lib/gnutls_cert.c
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2006-03-15 11:14:34 +0000
committerSimon Josefsson <simon@josefsson.org>2006-03-15 11:14:34 +0000
commitfbc4d973377a5e135cb4f41e31e6eb635df4bf98 (patch)
treeb39d61f7de1841f7bbcaf095189a7f389d300288 /lib/gnutls_cert.c
parentef078a58261c24b525f5893f07b95930a0342f83 (diff)
downloadgnutls-fbc4d973377a5e135cb4f41e31e6eb635df4bf98.tar.gz
Move from x509/compat.c.
Diffstat (limited to 'lib/gnutls_cert.c')
-rw-r--r--lib/gnutls_cert.c69
1 files changed, 68 insertions, 1 deletions
diff --git a/lib/gnutls_cert.c b/lib/gnutls_cert.c
index d70b62805b..c9a4a97dfe 100644
--- a/lib/gnutls_cert.c
+++ b/lib/gnutls_cert.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation
+ * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation
*
* Author: Nikos Mavroyanopoulos
*
@@ -374,6 +374,73 @@ OPENPGP_KEY_EXPIRATION_TIME_FUNC
_E_gnutls_openpgp_get_raw_key_expiration_time = NULL;
OPENPGP_VERIFY_KEY_FUNC _E_gnutls_openpgp_verify_key = NULL;
+
+/*-
+ * _gnutls_x509_extract_certificate_activation_time - This function returns the peer's certificate activation time
+ * @cert: should contain an X.509 DER encoded certificate
+ *
+ * This function will return the certificate's activation time in UNIX time
+ * (ie seconds since 00:00:00 UTC January 1, 1970).
+ *
+ * Returns a (time_t) -1 in case of an error.
+ *
+ -*/
+static time_t
+_gnutls_x509_get_raw_crt_activation_time(const gnutls_datum_t *cert)
+{
+ gnutls_x509_crt_t xcert;
+ time_t result;
+
+ result = gnutls_x509_crt_init(&xcert);
+ if (result < 0)
+ return (time_t) -1;
+
+ result = gnutls_x509_crt_import(xcert, cert, GNUTLS_X509_FMT_DER);
+ if (result < 0) {
+ gnutls_x509_crt_deinit(xcert);
+ return (time_t) -1;
+ }
+
+ result = gnutls_x509_crt_get_activation_time(xcert);
+
+ gnutls_x509_crt_deinit(xcert);
+
+ return result;
+}
+
+/*-
+ * gnutls_x509_extract_certificate_expiration_time - This function returns the certificate's expiration time
+ * @cert: should contain an X.509 DER encoded certificate
+ *
+ * This function will return the certificate's expiration time in UNIX
+ * time (ie seconds since 00:00:00 UTC January 1, 1970). Returns a
+ *
+ * (time_t) -1 in case of an error.
+ *
+ -*/
+static time_t
+_gnutls_x509_get_raw_crt_expiration_time(const gnutls_datum_t *cert)
+{
+ gnutls_x509_crt_t xcert;
+ time_t result;
+
+ result = gnutls_x509_crt_init(&xcert);
+ if (result < 0)
+ return (time_t) -1;
+
+ result = gnutls_x509_crt_import(xcert, cert, GNUTLS_X509_FMT_DER);
+ if (result < 0) {
+ gnutls_x509_crt_deinit(xcert);
+ return (time_t) -1;
+ }
+
+ result = gnutls_x509_crt_get_expiration_time(xcert);
+
+ gnutls_x509_crt_deinit(xcert);
+
+ return result;
+}
+
/*-
* _gnutls_openpgp_cert_verify_peers - This function returns the peer's certificate status
* @session: is a gnutls session