defined *_create_from_file() constructors in libstrongswan/credentials/certificates
[strongswan.git] / src / libstrongswan / credentials / certificates / crl.c
1 /*
2 * Copyright (C) 2008 Martin Willi
3 * Copyright (C) 2006 Andreas Steffen
4 * 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 * $Id$
17 */
18
19 #include <library.h>
20 #include <debug.h>
21 #include <asn1/pem.h>
22 #include "crl.h"
23
24 ENUM(crl_reason_names, CRL_UNSPECIFIED, CRL_REMOVE_FROM_CRL,
25 "unspecified",
26 "key compromise",
27 "ca compromise",
28 "affiliation changed",
29 "superseded",
30 "cessation of operation",
31 "certificate hold",
32 "reason #7",
33 "remove from crl",
34 );
35
36 /*
37 * Defined in header.
38 */
39 crl_t* crl_create_from_file(char *path)
40 {
41 crl_t *crl;
42 bool pgp = FALSE;
43 chunk_t chunk;
44
45 if (!pem_asn1_load_file(path, NULL, &chunk, &pgp))
46 {
47 DBG1(" could not load crl file '%s'", path);
48 return NULL;
49 }
50 crl = (crl_t*)lib->creds->create(lib->creds,
51 CRED_CERTIFICATE, CERT_X509_CRL,
52 BUILD_BLOB_ASN1_DER, chunk, BUILD_END);
53 if (crl == NULL)
54 {
55 DBG1(" could not parse loaded crl file '%s'", path);
56 return NULL;
57 }
58 DBG1(" loaded crl file '%s'", path);
59 return crl;
60 }