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
;
33 #define MAX_CA_PATH_LEN 7
35 /*forward declaration */
36 struct credential_store_t
;
39 * @brief X.509 certification authority information record
49 * @brief Compare two ca info records
51 * Comparison is done via the keyid of the ca certificate
53 * @param this first ca info object
54 * @param that second ca info objct
55 * @return TRUE if a match is found
57 bool (*equals
) (const ca_info_t
*this, const ca_info_t
* that
);
60 * @brief If the ca info record has the same name then release the name and URIs
62 * @param this ca info object
63 * @return TRUE if a match is found
65 bool (*equals_name_release_info
) (ca_info_t
*this, const char *name
);
68 * @brief Checks if a certificate was issued by this ca
70 * @param this ca info object
71 * @param cert certificate to be checked
72 * @return TRUE if the issuing ca has been found
74 bool (*is_cert_issuer
) (ca_info_t
*this, const x509_t
*cert
);
77 * @brief Checks if a crl was issued by this ca
79 * @param this ca info object
80 * @param crl crl to be checked
81 * @return TRUE if the issuing ca has been found
83 bool (*is_crl_issuer
) (ca_info_t
*this, const crl_t
*crl
);
86 * @brief Checks if the ca certificate has the isCA flag set
88 * @param this ca info object
89 * @return TRUE if the isCA flag is set
91 bool (*is_ca
) (ca_info_t
*this);
94 * @brief Checks if the ca enforces a strict crl policy
96 * @param this ca info object
97 * @return TRUE if the crl policy is strict
99 bool (*is_strict
) (ca_info_t
*this);
102 * @brief Merges info from a secondary ca info object
104 * @param this primary ca info object
105 * @param that secondary ca info object
107 void (*add_info
) (ca_info_t
*this, const ca_info_t
*that
);
110 * @brief Adds a new or replaces an obsoleted CRL
112 * @param this ca info object
113 * @param crl crl to be added
115 void (*add_crl
) (ca_info_t
*this, crl_t
*crl
);
118 * @brief Does the CA have a CRL?
120 * @param this ca info object
121 * @return TRUE if crl is available
123 bool (*has_crl
) (ca_info_t
*this);
126 * @brief Does the CA have OCSP certinfos?
128 * @param this ca info object
129 * @return TRUE if there are any certinfos
131 bool (*has_certinfos
) (ca_info_t
*this);
134 * @brief Print the CA info onto the console
136 * @param this ca info object
137 * @param out output stream
138 * @param utc TRUE - utc
141 void (*list
) (ca_info_t
*this, FILE *out
, bool utc
);
144 * @brief List the CRL onto the console
146 * @param this ca info object
147 * @param out output stream
148 * @param utc TRUE - utc
151 void (*list_crl
) (ca_info_t
*this, FILE *out
, bool utc
);
154 * @brief List the OCSP certinfos onto the console
156 * @param this ca info object
157 * @param out output stream
158 * @param utc TRUE - utc
161 void (*list_certinfos
) (ca_info_t
*this, FILE *out
, bool utc
);
164 * @brief Adds a CRL URI to a list
166 * @param this ca info object
167 * @param uri crl uri to be added
169 void (*add_crluri
) (ca_info_t
*this, chunk_t uri
);
172 * @brief Adds a OCSP URI to a list
174 * @param this ca info object
175 * @param uri ocsp uri to be added
177 void (*add_ocspuri
) (ca_info_t
*this, chunk_t uri
);
180 * @brief Get the ca certificate
182 * @param this ca info object
183 * @return ca certificate
185 x509_t
* (*get_certificate
) (ca_info_t
*this);
188 * @brief Verify the status of a certificate by CRL
190 * @param this ca info object
191 * @param certinfo detailed certificate status information
192 * @param crl_dir directory where fetched crls should be stored
193 * @return certificate status
195 cert_status_t (*verify_by_crl
) (ca_info_t
*this, certinfo_t
*certinfo
, const char *crl_dir
);
198 * @brief Verify the status of a certificate by OCSP
200 * @param this ca info object
201 * @param certinfo detailed certificate status information
202 * @param credentials credential store needed for trust path verification
203 * @return certificate status
205 cert_status_t (*verify_by_ocsp
) (ca_info_t
* this, certinfo_t
* certinfo
, struct credential_store_t
* credentials
);
208 * @brief Purge the OCSP certinfos of a ca info record
210 * @param this ca info object
212 void (*purge_ocsp
) (ca_info_t
*this);
215 * @brief Destroys a ca info record
217 * @param this ca info to destroy
219 void (*destroy
) (ca_info_t
*this);
223 * @brief Set ca info options
225 * @param cache TRUE if crls shall be cached by storing them
226 * @param interval crl_check_interval to be set in seconds
230 void ca_info_set_options(strict_t strict
, bool cache
, u_int interval
);
233 * @brief Create a ca info record
235 * @param name name of the ca info record
236 * @param cacert path to the ca certificate
237 * @return created ca_info_t, or NULL if invalid.
241 ca_info_t
*ca_info_create(const char *name
, x509_t
*cacert
);