Annotation of embedaddon/strongswan/src/libstrongswan/credentials/certificates/certificate.c, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 2007 Martin Willi
3: * Copyright (C) 2015 Andreas Steffen
4: * HSR Hochschule fuer Technik Rapperswil
5: *
6: * This program is free software; you can redistribute it and/or modify it
7: * under the terms of the GNU General Public License as published by the
8: * Free Software Foundation; either version 2 of the License, or (at your
9: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * for more details.
15: */
16:
17: #include "certificate.h"
18:
19: #include <utils/debug.h>
20: #include <credentials/certificates/x509.h>
21:
22: ENUM(certificate_type_names, CERT_ANY, CERT_GPG,
23: "ANY",
24: "X509",
25: "X509_CRL",
26: "OCSP_REQUEST",
27: "OCSP_RESPONSE",
28: "X509_AC",
29: "PUBKEY",
30: "PKCS10_REQUEST",
31: "PGP",
32: );
33:
34: ENUM(cert_validation_names, VALIDATION_GOOD, VALIDATION_REVOKED,
35: "GOOD",
36: "SKIPPED",
37: "STALE",
38: "FAILED",
39: "ON_HOLD",
40: "REVOKED",
41: );
42:
43: /**
44: * See header
45: */
46: bool certificate_is_newer(certificate_t *this, certificate_t *other)
47: {
48: time_t this_update, that_update;
49: char *type = "certificate";
50: bool newer;
51:
52: if (this->get_type(this) == CERT_X509_CRL)
53: {
54: type = "crl";
55: }
56: this->get_validity(this, NULL, &this_update, NULL);
57: other->get_validity(other, NULL, &that_update, NULL);
58: newer = this_update > that_update;
59: DBG1(DBG_LIB, " %s from %T is %s - existing %s from %T %s",
60: type, &this_update, FALSE, newer ? "newer" : "not newer",
61: type, &that_update, FALSE, newer ? "replaced" : "retained");
62: return newer;
63: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>