8#ifndef BOTAN_X509_CERT_PATH_VALIDATION_H_
9#define BOTAN_X509_CERT_PATH_VALIDATION_H_
11#include <botan/certstor.h>
12#include <botan/ocsp.h>
13#include <botan/pkix_enums.h>
14#include <botan/x509cert.h>
19#if defined(BOTAN_TARGET_OS_HAS_THREADS) && defined(BOTAN_HAS_HTTP_UTIL)
20 #define BOTAN_HAS_ONLINE_REVOCATION_CHECKS
57 bool require_rev =
false,
58 size_t minimum_key_strength = 110,
59 bool ocsp_all_intermediates =
false,
60 std::chrono::seconds max_ocsp_age = std::chrono::seconds::zero(),
61 std::unique_ptr<Certificate_Store> trusted_ocsp_responders = std::make_unique<Certificate_Store_In_Memory>(),
62 bool ignore_trusted_root_time_range =
false);
83 size_t minimum_key_strength,
84 bool ocsp_all_intermediates,
85 const std::set<std::string>& trusted_hashes,
86 std::chrono::seconds max_ocsp_age = std::chrono::seconds::zero(),
87 std::unique_ptr<Certificate_Store> trusted_ocsp_responders = std::make_unique<Certificate_Store_In_Memory>(),
88 bool ignore_trusted_root_time_range =
false) :
89 m_require_revocation_information(require_rev),
90 m_ocsp_all_intermediates(ocsp_all_intermediates),
91 m_trusted_hashes(trusted_hashes),
92 m_minimum_key_strength(minimum_key_strength),
93 m_max_ocsp_age(max_ocsp_age),
94 m_trusted_ocsp_responders(std::move(trusted_ocsp_responders)),
95 m_ignore_trusted_root_time_range(ignore_trusted_root_time_range) {}
145 bool m_require_revocation_information;
146 bool m_ocsp_all_intermediates;
147 std::set<std::string> m_trusted_hashes;
148 size_t m_minimum_key_strength;
149 std::chrono::seconds m_max_ocsp_age;
150 std::unique_ptr<Certificate_Store> m_trusted_ocsp_responders;
151 bool m_ignore_trusted_root_time_range;
171 const std::vector<X509_Certificate>&
cert_path()
const {
return m_cert_path; }
176 bool successful_validation()
const;
181 bool no_warnings()
const;
201 std::string result_string()
const;
206 std::string warnings_string()
const;
230 std::vector<X509_Certificate> m_cert_path;
251 const Path_Validation_Restrictions& restrictions,
252 const std::vector<Certificate_Store*>& trusted_roots,
253 std::string_view hostname = "",
255 std::chrono::system_clock::time_point validation_time = std::chrono::system_clock::now(),
256 std::chrono::milliseconds ocsp_timeout = std::chrono::milliseconds(0),
257 const std::vector<std::optional<OCSP::Response>>& ocsp_resp = {});
273 const Path_Validation_Restrictions& restrictions,
274 const std::vector<Certificate_Store*>& trusted_roots,
275 std::string_view hostname = "",
277 std::chrono::system_clock::time_point validation_time = std::chrono::system_clock::now(),
278 std::chrono::milliseconds ocsp_timeout = std::chrono::milliseconds(0),
279 const std::vector<std::optional<OCSP::Response>>& ocsp_resp = {});
295 const Path_Validation_Restrictions& restrictions,
296 const Certificate_Store& store,
297 std::string_view hostname = "",
299 std::chrono::system_clock::time_point validation_time = std::chrono::system_clock::now(),
300 std::chrono::milliseconds ocsp_timeout = std::chrono::milliseconds(0),
301 const std::vector<std::optional<OCSP::Response>>& ocsp_resp = {});
317 const Path_Validation_Restrictions& restrictions,
318 const Certificate_Store& store,
319 std::string_view hostname = "",
321 std::chrono::system_clock::time_point validation_time = std::chrono::system_clock::now(),
322 std::chrono::milliseconds ocsp_timeout = std::chrono::milliseconds(0),
323 const std::vector<std::optional<OCSP::Response>>& ocsp_resp = {});
334 const std::vector<Certificate_Store*>& trusted_certstores,
335 const std::optional<X509_Certificate>& end_entity,
336 const std::vector<X509_Certificate>& end_entity_extra);
368 std::chrono::system_clock::time_point ref_time,
369 std::string_view hostname,
385 const std::vector<std::optional<OCSP::Response>>& ocsp_responses,
387 std::chrono::system_clock::time_point ref_time,
400 const std::vector<std::optional<
X509_CRL>>& crls,
401 std::chrono::system_clock::time_point ref_time);
413 std::chrono::system_clock::time_point ref_time);
415#if defined(BOTAN_HAS_ONLINE_REVOCATION_CHECKS)
433 std::chrono::system_clock::time_point ref_time,
434 std::chrono::milliseconds timeout,
455 std::chrono::system_clock::time_point ref_time,
456 std::chrono::milliseconds timeout);
bool require_revocation_information() const
bool ocsp_all_intermediates() const
const std::set< std::string > & trusted_hashes() const
std::chrono::seconds max_ocsp_age() const
Path_Validation_Restrictions(bool require_rev, size_t minimum_key_strength, bool ocsp_all_intermediates, const std::set< std::string > &trusted_hashes, std::chrono::seconds max_ocsp_age=std::chrono::seconds::zero(), std::unique_ptr< Certificate_Store > trusted_ocsp_responders=std::make_unique< Certificate_Store_In_Memory >(), bool ignore_trusted_root_time_range=false)
bool ignore_trusted_root_time_range() const
size_t minimum_key_strength() const
const Certificate_Store * trusted_ocsp_responders() const
Certificate_Status_Code result() const
Path_Validation_Result(Certificate_Status_Code status)
const std::vector< X509_Certificate > & cert_path() const
Certificate_Status_Code Code
const CertificatePathStatusCodes & all_statuses() const
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
void merge_revocation_status(CertificatePathStatusCodes &chain_status, const CertificatePathStatusCodes &crl_status, const CertificatePathStatusCodes &ocsp_status, const Path_Validation_Restrictions &restrictions)
Certificate_Status_Code build_certificate_path(std::vector< X509_Certificate > &cert_path_out, const std::vector< Certificate_Store * > &trusted_certstores, const X509_Certificate &end_entity, const std::vector< X509_Certificate > &end_entity_extra)
Certificate_Status_Code overall_status(const CertificatePathStatusCodes &cert_status)
CertificatePathStatusCodes check_ocsp(const std::vector< X509_Certificate > &cert_path, const std::vector< std::optional< OCSP::Response > > &ocsp_responses, const std::vector< Certificate_Store * > &certstores, std::chrono::system_clock::time_point ref_time, const Path_Validation_Restrictions &restrictions)
Certificate_Status_Code build_all_certificate_paths(std::vector< std::vector< X509_Certificate > > &cert_paths, const std::vector< Certificate_Store * > &trusted_certstores, const std::optional< X509_Certificate > &end_entity, const std::vector< X509_Certificate > &end_entity_extra)
CertificatePathStatusCodes check_chain(const std::vector< X509_Certificate > &cert_path, std::chrono::system_clock::time_point ref_time, std::string_view hostname, Usage_Type usage, const Path_Validation_Restrictions &restrictions)
CertificatePathStatusCodes check_crl(const std::vector< X509_Certificate > &cert_path, const std::vector< std::optional< X509_CRL > > &crls, std::chrono::system_clock::time_point ref_time)
std::vector< std::set< Certificate_Status_Code > > CertificatePathStatusCodes
Path_Validation_Result x509_path_validate(const std::vector< X509_Certificate > &end_certs, const Path_Validation_Restrictions &restrictions, const std::vector< Certificate_Store * > &trusted_roots, std::string_view hostname, Usage_Type usage, std::chrono::system_clock::time_point ref_time, std::chrono::milliseconds ocsp_timeout, const std::vector< std::optional< OCSP::Response > > &ocsp_resp)