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>
18#if defined(BOTAN_TARGET_OS_HAS_THREADS) && defined(BOTAN_HAS_HTTP_UTIL)
19 #define BOTAN_HAS_ONLINE_REVOCATION_CHECKS
59 bool require_rev =
false,
62 std::chrono::seconds
max_ocsp_age = std::chrono::seconds::zero(),
92 std::chrono::seconds
max_ocsp_age = std::chrono::seconds::zero(),
96 m_require_revocation_information(require_rev),
162 bool m_require_revocation_information;
163 bool m_ocsp_all_intermediates;
164 std::set<std::string> m_trusted_hashes;
165 size_t m_minimum_key_strength;
166 std::chrono::seconds m_max_ocsp_age;
167 std::unique_ptr<Certificate_Store> m_trusted_ocsp_responders;
168 bool m_ignore_trusted_root_time_range;
169 bool m_require_self_signed_trust_anchors;
189 const std::vector<X509_Certificate>&
cert_path()
const {
return m_cert_path; }
194 bool successful_validation()
const;
199 bool no_warnings()
const;
219 std::string result_string()
const;
224 std::string warnings_string()
const;
248 std::vector<X509_Certificate> m_cert_path;
269 const Path_Validation_Restrictions& restrictions,
270 const std::vector<Certificate_Store*>& trusted_roots,
271 std::string_view hostname =
"",
273 std::chrono::system_clock::time_point validation_time = std::chrono::system_clock::now(),
274 std::chrono::milliseconds ocsp_timeout = std::chrono::milliseconds(0),
275 const std::vector<std::optional<OCSP::Response>>& ocsp_resp = {});
293 std::string_view hostname =
"",
295 std::chrono::system_clock::time_point validation_time = std::chrono::system_clock::now(),
296 std::chrono::milliseconds ocsp_timeout = std::chrono::milliseconds(0),
297 const std::vector<std::optional<
OCSP::Response>>& ocsp_resp = {});
315 std::string_view hostname =
"",
317 std::chrono::system_clock::time_point validation_time = std::chrono::system_clock::now(),
318 std::chrono::milliseconds ocsp_timeout = std::chrono::milliseconds(0),
319 const std::vector<std::optional<
OCSP::Response>>& ocsp_resp = {});
337 std::string_view hostname =
"",
339 std::chrono::system_clock::time_point validation_time = std::chrono::system_clock::now(),
340 std::chrono::milliseconds ocsp_timeout = std::chrono::milliseconds(0),
341 const std::vector<std::optional<
OCSP::Response>>& ocsp_resp = {});
368 const std::vector<Certificate_Store*>& trusted_certstores,
370 const std::vector<X509_Certificate>& end_entity_extra);
389 const std::vector<Certificate_Store*>& trusted_certstores,
391 const std::vector<X509_Certificate>& end_entity_extra);
409 std::chrono::system_clock::time_point ref_time,
410 std::string_view hostname,
425 check_ocsp(
const std::vector<X509_Certificate>& cert_path,
426 const std::vector<std::optional<OCSP::Response>>& ocsp_responses,
427 const std::vector<Certificate_Store*>& certstores,
428 std::chrono::system_clock::time_point ref_time,
441 const std::vector<std::optional<X509_CRL>>& crls,
442 std::chrono::system_clock::time_point ref_time);
453 const std::vector<Certificate_Store*>& certstores,
454 std::chrono::system_clock::time_point ref_time);
456#if defined(BOTAN_HAS_ONLINE_REVOCATION_CHECKS)
472 check_ocsp_online(
const std::vector<X509_Certificate>& cert_path,
473 const std::vector<Certificate_Store*>& trusted_certstores,
474 std::chrono::system_clock::time_point ref_time,
475 std::chrono::milliseconds timeout,
493 check_crl_online(
const std::vector<X509_Certificate>& cert_path,
494 const std::vector<Certificate_Store*>& trusted_certstores,
496 std::chrono::system_clock::time_point ref_time,
497 std::chrono::milliseconds timeout);
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_DEPRECATED(msg)
#define BOTAN_FUTURE_EXPLICIT
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
bool ignore_trusted_root_time_range() const
bool require_self_signed_trust_anchors() const
size_t minimum_key_strength() const
const Certificate_Store * trusted_ocsp_responders() 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 require_self_signed_trust_anchors=true)
BOTAN_FUTURE_EXPLICIT Path_Validation_Restrictions(bool require_rev=false, size_t minimum_key_strength=110, bool ocsp_all_intermediates=false, 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 require_self_signed_trust_anchors=true)
Certificate_Status_Code result() const
Certificate_Status_Code Code
Path_Validation_Result(Certificate_Status_Code status)
const std::vector< X509_Certificate > & cert_path() const
Path_Validation_Result(CertificatePathStatusCodes status, std::vector< X509_Certificate > &&cert_chain)
const X509_Certificate & trust_root() const
const CertificatePathStatusCodes & all_statuses() const
Certificate_Status_Code build_all_certificate_paths(std::vector< std::vector< X509_Certificate > > &cert_paths, const std::vector< Certificate_Store * > &trusted_certstores, const X509_Certificate &end_entity, const std::vector< X509_Certificate > &end_entity_extra)
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)
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)