4 * @brief Interface of ca_info_t.
9 * Copyright (C) 2007 Andreas Steffen
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 typedef struct ca_info_t ca_info_t
;
30 #include <credential_store.h>
36 * @brief X.509 certification authority information record
46 * @brief Compare two ca info records
48 * Comparison is done via the keyid of the ca certificate
50 * @param this first ca info object
51 * @param that second ca info objct
52 * @return TRUE if a match is found
54 bool (*equals
) (const ca_info_t
*this, const ca_info_t
* that
);
57 * @brief If the ca info record has the same name then release the name and URIs
59 * @param this ca info object
60 * @return TRUE if a match is found
62 bool (*equals_name_release_info
) (ca_info_t
*this, const char *name
);
65 * @brief Checks if a certificate was issued by this ca
67 * @param this ca info object
68 * @param cert certificate to be checked
69 * @return TRUE if the issuing ca has been found
71 bool (*is_cert_issuer
) (ca_info_t
*this, const x509_t
*cert
);
74 * @brief Checks if a crl was issued by this ca
76 * @param this ca info object
77 * @param crl crl to be checked
78 * @return TRUE if the issuing ca has been found
80 bool (*is_crl_issuer
) (ca_info_t
*this, const crl_t
*crl
);
83 * @brief Checks if the ca enforces a strict crl policy
85 * @param this ca info object
86 * @return TRUE if the crl policy is strict
88 bool (*is_strict
) (ca_info_t
*this);
91 * @brief Merges info from a secondary ca info object
93 * @param this primary ca info object
94 * @param that secondary ca info object
96 void (*add_info
) (ca_info_t
*this, const ca_info_t
*that
);
99 * @brief Adds a new or replaces an obsoleted CRL
101 * @param this ca info object
102 * @param crl crl to be added
104 void (*add_crl
) (ca_info_t
*this, crl_t
*crl
);
107 * @brief Does the CA have a CRL?
109 * @param this ca info object
110 * @return TRUE if crl is available
112 bool (*has_crl
) (ca_info_t
*this);
115 * @brief Does the CA have OCSP certinfos?
117 * @param this ca info object
118 * @return TRUE if there are any certinfos
120 bool (*has_certinfos
) (ca_info_t
*this);
123 * @brief Print the CA info onto the console
125 * @param this ca info object
126 * @param out output stream
127 * @param utc TRUE - utc
130 void (*list
) (ca_info_t
*this, FILE *out
, bool utc
);
133 * @brief List the CRL onto the console
135 * @param this ca info object
136 * @param out output stream
137 * @param utc TRUE - utc
140 void (*list_crl
) (ca_info_t
*this, FILE *out
, bool utc
);
143 * @brief List the OCSP certinfos onto the console
145 * @param this ca info object
146 * @param out output stream
147 * @param utc TRUE - utc
150 void (*list_certinfos
) (ca_info_t
*this, FILE *out
, bool utc
);
153 * @brief Adds a CRL URI to a list
155 * @param this ca info object
156 * @param uri crl uri to be added
158 void (*add_crluri
) (ca_info_t
*this, chunk_t uri
);
161 * @brief Adds a OCSP URI to a list
163 * @param this ca info object
164 * @param uri ocsp uri to be added
166 void (*add_ocspuri
) (ca_info_t
*this, chunk_t uri
);
169 * @brief Get the ca certificate
171 * @param this ca info object
172 * @return ca certificate
174 x509_t
* (*get_certificate
) (ca_info_t
*this);
177 * @brief Verify the status of a certificate by CRL
179 * @param this ca info object
180 * @param certinfo detailed certificate status information
181 * @param crl_dir directory where fetched crls should be stored
182 * @return certificate status
184 cert_status_t (*verify_by_crl
) (ca_info_t
*this, certinfo_t
*certinfo
, const char *crl_dir
);
187 * @brief Verify the status of a certificate by OCSP
189 * @param this ca info object
190 * @param certinfo detailed certificate status information
191 * @param credentials credential store needed for trust path verification
192 * @return certificate status
194 cert_status_t (*verify_by_ocsp
) (ca_info_t
* this, certinfo_t
* certinfo
, credential_store_t
* credentials
);
197 * @brief Purge the OCSP certinfos of a ca info record
199 * @param this ca info object
201 void (*purge_ocsp
) (ca_info_t
*this);
204 * @brief Destroys a ca info record
206 * @param this ca info to destroy
208 void (*destroy
) (ca_info_t
*this);
212 * @brief Set ca info options
214 * @param cache TRUE if crls shall be cached by storing them
215 * @param interval crl_check_interval to be set in seconds
219 void ca_info_set_options(strict_t strict
, bool cache
, u_int interval
);
222 * @brief Create a ca info record
224 * @param name name of the ca info record
225 * @param cacert path to the ca certificate
226 * @return created ca_info_t, or NULL if invalid.
230 ca_info_t
*ca_info_create(const char *name
, x509_t
*cacert
);