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
65 bool require_rev =
false,
68 std::chrono::seconds
max_ocsp_age = std::chrono::hours(24 * 7),
103 std::chrono::seconds
max_ocsp_age = std::chrono::hours(24 * 7),
108 m_require_revocation_information(require_rev),
183 bool m_require_revocation_information;
184 bool m_ocsp_all_intermediates;
185 std::set<std::string> m_trusted_hashes;
186 size_t m_minimum_key_strength;
187 std::chrono::seconds m_max_ocsp_age;
188 std::unique_ptr<Certificate_Store> m_trusted_ocsp_responders;
189 bool m_ignore_trusted_root_time_range;
190 bool m_require_self_signed_trust_anchors;
191 bool m_accept_ocsp_softfail;
211 const std::vector<X509_Certificate>&
cert_path()
const {
return m_cert_path; }
216 bool successful_validation()
const;
221 bool no_warnings()
const;
241 std::string result_string()
const;
246 std::string warnings_string()
const;
270 std::vector<X509_Certificate> m_cert_path;
288 const Path_Validation_Restrictions& restrictions,
289 const std::vector<Certificate_Store*>& trusted_roots,
290 std::string_view hostname =
"",
292 std::chrono::system_clock::time_point validation_time = std::chrono::system_clock::now(),
293 std::chrono::milliseconds ocsp_timeout = std::chrono::milliseconds(0),
294 const std::vector<std::optional<OCSP::Response>>& ocsp_resp = {});
312 std::string_view hostname =
"",
314 std::chrono::system_clock::time_point validation_time = std::chrono::system_clock::now(),
315 std::chrono::milliseconds ocsp_timeout = std::chrono::milliseconds(0),
316 const std::vector<std::optional<
OCSP::Response>>& ocsp_resp = {});
334 std::string_view hostname =
"",
336 std::chrono::system_clock::time_point validation_time = std::chrono::system_clock::now(),
337 std::chrono::milliseconds ocsp_timeout = std::chrono::milliseconds(0),
338 const std::vector<std::optional<
OCSP::Response>>& ocsp_resp = {});
356 std::string_view hostname =
"",
358 std::chrono::system_clock::time_point validation_time = std::chrono::system_clock::now(),
359 std::chrono::milliseconds ocsp_timeout = std::chrono::milliseconds(0),
360 const std::vector<std::optional<
OCSP::Response>>& ocsp_resp = {});
389 const std::vector<Certificate_Store*>& trusted_certstores,
391 const std::vector<X509_Certificate>& end_entity_extra,
392 std::optional<size_t> max_paths = std::nullopt);
412 const std::vector<Certificate_Store*>& trusted_certstores,
414 const std::vector<X509_Certificate>& end_entity_extra,
415 std::optional<size_t> max_paths = std::nullopt);
433 std::chrono::system_clock::time_point ref_time,
434 std::string_view hostname,
449 check_ocsp(
const std::vector<X509_Certificate>& cert_path,
450 const std::vector<std::optional<OCSP::Response>>& ocsp_responses,
451 const std::vector<Certificate_Store*>& certstores,
452 std::chrono::system_clock::time_point ref_time,
465 const std::vector<std::optional<X509_CRL>>& crls,
466 std::chrono::system_clock::time_point ref_time);
477 const std::vector<Certificate_Store*>& certstores,
478 std::chrono::system_clock::time_point ref_time);
480#if defined(BOTAN_HAS_ONLINE_REVOCATION_CHECKS)
496 check_ocsp_online(
const std::vector<X509_Certificate>& cert_path,
497 const std::vector<Certificate_Store*>& trusted_certstores,
498 std::chrono::system_clock::time_point ref_time,
499 std::chrono::milliseconds timeout,
517 check_crl_online(
const std::vector<X509_Certificate>& cert_path,
518 const std::vector<Certificate_Store*>& trusted_certstores,
520 std::chrono::system_clock::time_point ref_time,
521 std::chrono::milliseconds timeout);
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_DEPRECATED(msg)
#define BOTAN_FUTURE_EXPLICIT
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::hours(24 *7), std::unique_ptr< Certificate_Store > trusted_ocsp_responders=nullptr, bool ignore_trusted_root_time_range=false, bool require_self_signed_trust_anchors=true, bool accept_ocsp_softfail=false)
bool require_revocation_information() const
bool ocsp_all_intermediates() const
const std::set< std::string > & trusted_hashes() const
bool accept_ocsp_softfail() 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
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::hours(24 *7), std::unique_ptr< Certificate_Store > trusted_ocsp_responders=nullptr, bool ignore_trusted_root_time_range=false, bool require_self_signed_trust_anchors=true, bool accept_ocsp_softfail=false)
const Certificate_Store * trusted_ocsp_responders() const
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
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, std::optional< size_t > max_paths=std::nullopt)
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, std::optional< size_t > max_paths=std::nullopt)
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)