Botan 3.6.1
Crypto and TLS for C&
certstor_system.cpp
Go to the documentation of this file.
1/*
2* (C) 2019 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#include <botan/certstor_system.h>
8
9#include <botan/pkix_types.h>
10#include <botan/x509cert.h>
11
12#if defined(BOTAN_HAS_CERTSTOR_MACOS)
13 #include <botan/certstor_macos.h>
14#elif defined(BOTAN_HAS_CERTSTOR_WINDOWS)
15 #include <botan/certstor_windows.h>
16#elif defined(BOTAN_HAS_CERTSTOR_FLATFILE) && defined(BOTAN_SYSTEM_CERT_BUNDLE)
17 #include <botan/certstor_flatfile.h>
18#endif
19
20namespace Botan {
21
23#if defined(BOTAN_HAS_CERTSTOR_MACOS)
24 m_system_store = std::make_shared<Certificate_Store_MacOS>();
25#elif defined(BOTAN_HAS_CERTSTOR_WINDOWS)
26 m_system_store = std::make_shared<Certificate_Store_Windows>();
27#elif defined(BOTAN_HAS_CERTSTOR_FLATFILE) && defined(BOTAN_SYSTEM_CERT_BUNDLE)
28 m_system_store = std::make_shared<Flatfile_Certificate_Store>(BOTAN_SYSTEM_CERT_BUNDLE, true);
29#else
30 throw Not_Implemented("No system certificate store available in this build");
31#endif
32}
33
34std::optional<X509_Certificate> System_Certificate_Store::find_cert(const X509_DN& subject_dn,
35 const std::vector<uint8_t>& key_id) const {
36 return m_system_store->find_cert(subject_dn, key_id);
37}
38
39std::vector<X509_Certificate> System_Certificate_Store::find_all_certs(const X509_DN& subject_dn,
40 const std::vector<uint8_t>& key_id) const {
41 return m_system_store->find_all_certs(subject_dn, key_id);
42}
43
45 const std::vector<uint8_t>& key_hash) const {
46 return m_system_store->find_cert_by_pubkey_sha1(key_hash);
47}
48
50 const std::vector<uint8_t>& subject_hash) const {
51 return m_system_store->find_cert_by_raw_subject_dn_sha256(subject_hash);
52}
53
54std::optional<X509_CRL> System_Certificate_Store::find_crl_for(const X509_Certificate& subject) const {
55 return m_system_store->find_crl_for(subject);
56}
57
58std::vector<X509_DN> System_Certificate_Store::all_subjects() const {
59 return m_system_store->all_subjects();
60}
61
62} // namespace Botan
std::vector< X509_DN > all_subjects() const override
std::optional< X509_Certificate > find_cert_by_raw_subject_dn_sha256(const std::vector< uint8_t > &subject_hash) const override
std::vector< X509_Certificate > find_all_certs(const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) const override
std::optional< X509_CRL > find_crl_for(const X509_Certificate &subject) const override
std::optional< X509_Certificate > find_cert_by_pubkey_sha1(const std::vector< uint8_t > &key_hash) const override
std::optional< X509_Certificate > find_cert(const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) const override
#define BOTAN_SYSTEM_CERT_BUNDLE
Definition build.h:82