1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*
* Copyright (C) 2002,2003 Nikos Mavroyanopoulos
* Copyright (C) 2004 Free Software Foundation
*
* This file is part of GNUTLS.
*
* The GNUTLS library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/* This file includes all functions that were in the 0.5.x and 0.8.x
* gnutls API. They are now implemented over the new certificate parsing
* API.
*/
#include <gnutls/x509.h>
/**
* 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.
*
**/
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 result;
result = gnutls_x509_crt_import(xcert, cert, GNUTLS_X509_FMT_DER);
if (result < 0) {
gnutls_x509_crt_deinit(xcert);
return result;
}
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.
*
**/
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 result;
result = gnutls_x509_crt_import(xcert, cert, GNUTLS_X509_FMT_DER);
if (result < 0) {
gnutls_x509_crt_deinit(xcert);
return result;
}
result = gnutls_x509_crt_get_expiration_time(xcert);
gnutls_x509_crt_deinit(xcert);
return result;
}
|