Botan 3.9.0
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#include <botan/internal/target_info.h>
12
13#if defined(BOTAN_HAS_CERTSTOR_MACOS)
14 #include <botan/certstor_macos.h>
15#elif defined(BOTAN_HAS_CERTSTOR_WINDOWS)
16 #include <botan/certstor_windows.h>
17#elif defined(BOTAN_HAS_CERTSTOR_FLATFILE) && defined(BOTAN_SYSTEM_CERT_BUNDLE)
18 #include <botan/certstor_flatfile.h>
19#endif
20
21namespace Botan {
22
24#if defined(BOTAN_HAS_CERTSTOR_MACOS)
25 m_system_store = std::make_shared<Certificate_Store_MacOS>();
26#elif defined(BOTAN_HAS_CERTSTOR_WINDOWS)
27 m_system_store = std::make_shared<Certificate_Store_Windows>();
28#elif defined(BOTAN_HAS_CERTSTOR_FLATFILE) && defined(BOTAN_SYSTEM_CERT_BUNDLE)
29 m_system_store = std::make_shared<Flatfile_Certificate_Store>(BOTAN_SYSTEM_CERT_BUNDLE, true);
30#else
31 throw Not_Implemented("No system certificate store available in this build");
32#endif
33}
34
35std::optional<X509_Certificate> System_Certificate_Store::find_cert(const X509_DN& subject_dn,
36 const std::vector<uint8_t>& key_id) const {
37 return m_system_store->find_cert(subject_dn, key_id);
38}
39
40std::vector<X509_Certificate> System_Certificate_Store::find_all_certs(const X509_DN& subject_dn,
41 const std::vector<uint8_t>& key_id) const {
42 return m_system_store->find_all_certs(subject_dn, key_id);
43}
44
46 const std::vector<uint8_t>& key_hash) const {
47 return m_system_store->find_cert_by_pubkey_sha1(key_hash);
48}
49
51 const std::vector<uint8_t>& subject_hash) const {
52 return m_system_store->find_cert_by_raw_subject_dn_sha256(subject_hash);
53}
54
55std::optional<X509_CRL> System_Certificate_Store::find_crl_for(const X509_Certificate& subject) const {
56 return m_system_store->find_crl_for(subject);
57}
58
59std::vector<X509_DN> System_Certificate_Store::all_subjects() const {
60 return m_system_store->all_subjects();
61}
62
63} // 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