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
66 bool require_rev =
false,
69 std::chrono::seconds
max_ocsp_age = std::chrono::hours(24 * 7),
105 std::chrono::seconds
max_ocsp_age = std::chrono::hours(24 * 7),
110 m_require_revocation_information(require_rev),
186 bool m_require_revocation_information;
187 bool m_ocsp_all_intermediates;
188 std::set<std::string> m_trusted_hashes;
189 size_t m_minimum_key_strength;
190 std::chrono::seconds m_max_ocsp_age;
191 std::unique_ptr<Certificate_Store> m_trusted_ocsp_responders;
192 bool m_ignore_trusted_root_time_range;
193 bool m_require_self_signed_trust_anchors;
194 bool m_accept_ocsp_softfail;
214 const std::vector<X509_Certificate>&
cert_path()
const {
return m_cert_path; }
219 bool successful_validation()
const;
224 bool no_warnings()
const;
244 std::string result_string()
const;
249 std::string warnings_string()
const;
273 std::vector<X509_Certificate> m_cert_path;
291 const Path_Validation_Restrictions& restrictions,
292 const std::vector<Certificate_Store*>& trusted_roots,
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 = {});
359 std::string_view hostname =
"",
361 std::chrono::system_clock::time_point validation_time = std::chrono::system_clock::now(),
362 std::chrono::milliseconds ocsp_timeout = std::chrono::milliseconds(0),
363 const std::vector<std::optional<
OCSP::Response>>& ocsp_resp = {});
392 const std::vector<Certificate_Store*>& trusted_certstores,
394 const std::vector<X509_Certificate>& end_entity_extra,
395 std::optional<size_t> max_paths = std::nullopt);
415 const std::vector<Certificate_Store*>& trusted_certstores,
417 const std::vector<X509_Certificate>& end_entity_extra,
418 std::optional<size_t> max_paths = std::nullopt);
437 std::chrono::system_clock::time_point ref_time,
438 std::string_view hostname,
453 check_ocsp(
const std::vector<X509_Certificate>& cert_path,
454 const std::vector<std::optional<OCSP::Response>>& ocsp_responses,
455 const std::vector<Certificate_Store*>& certstores,
456 std::chrono::system_clock::time_point ref_time,
470 const std::vector<std::optional<X509_CRL>>& crls,
471 std::chrono::system_clock::time_point ref_time,
481 const std::vector<std::optional<X509_CRL>>& crls,
482 std::chrono::system_clock::time_point ref_time);
494 const std::vector<Certificate_Store*>& certstores,
495 std::chrono::system_clock::time_point ref_time,
505 const std::vector<Certificate_Store*>& certstores,
506 std::chrono::system_clock::time_point ref_time);
508#if defined(BOTAN_HAS_ONLINE_REVOCATION_CHECKS)
524 check_ocsp_online(
const std::vector<X509_Certificate>& cert_path,
525 const std::vector<Certificate_Store*>& trusted_certstores,
526 std::chrono::system_clock::time_point ref_time,
527 std::chrono::milliseconds timeout,
546 check_crl_online(
const std::vector<X509_Certificate>& cert_path,
547 const std::vector<Certificate_Store*>& trusted_certstores,
549 std::chrono::system_clock::time_point ref_time,
550 std::chrono::milliseconds timeout,
560 check_crl_online(
const std::vector<X509_Certificate>& cert_path,
561 const std::vector<Certificate_Store*>& trusted_certstores,
563 std::chrono::system_clock::time_point ref_time,
564 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)
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, 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 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)
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)