Botan 3.4.0
Crypto and TLS for C&
Public Member Functions | List of all members
Botan::System_Certificate_Store Class Referencefinal

#include <certstor_system.h>

Inheritance diagram for Botan::System_Certificate_Store:
Botan::Certificate_Store

Public Member Functions

std::vector< X509_DNall_subjects () const override
 
bool certificate_known (const X509_Certificate &cert) const
 
std::vector< X509_Certificatefind_all_certs (const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) const override
 
std::optional< X509_Certificatefind_cert (const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) const override
 
std::optional< X509_Certificatefind_cert_by_pubkey_sha1 (const std::vector< uint8_t > &key_hash) const override
 
std::optional< X509_Certificatefind_cert_by_raw_subject_dn_sha256 (const std::vector< uint8_t > &subject_hash) const override
 
std::optional< X509_CRLfind_crl_for (const X509_Certificate &subject) const override
 
 System_Certificate_Store ()
 

Detailed Description

Definition at line 14 of file certstor_system.h.

Constructor & Destructor Documentation

◆ System_Certificate_Store()

Botan::System_Certificate_Store::System_Certificate_Store ( )

Definition at line 22 of file certstor_system.cpp.

22 {
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}
#define BOTAN_SYSTEM_CERT_BUNDLE
Definition build.h:61

References BOTAN_SYSTEM_CERT_BUNDLE.

Member Function Documentation

◆ all_subjects()

std::vector< X509_DN > Botan::System_Certificate_Store::all_subjects ( ) const
overridevirtual

Implements Botan::Certificate_Store.

Definition at line 58 of file certstor_system.cpp.

58 {
59 return m_system_store->all_subjects();
60}

◆ certificate_known()

bool Botan::Certificate_Store::certificate_known ( const X509_Certificate & cert) const
inlineinherited
Returns
whether the certificate is known
Parameters
certcertififcate to be searched

Definition at line 70 of file certstor.h.

70 {
71 return find_cert(cert.subject_dn(), cert.subject_key_id()).has_value();
72 }
virtual std::optional< X509_Certificate > find_cert(const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) const
Definition certstor.cpp:20

References Botan::X509_Certificate::subject_dn(), and Botan::X509_Certificate::subject_key_id().

◆ find_all_certs()

std::vector< X509_Certificate > Botan::System_Certificate_Store::find_all_certs ( const X509_DN & subject_dn,
const std::vector< uint8_t > & key_id ) const
overridevirtual

Find all certificates with a given Subject DN. Subject DN and even the key identifier might not be unique.

Implements Botan::Certificate_Store.

Definition at line 39 of file certstor_system.cpp.

40 {
41 return m_system_store->find_all_certs(subject_dn, key_id);
42}

◆ find_cert()

std::optional< X509_Certificate > Botan::System_Certificate_Store::find_cert ( const X509_DN & subject_dn,
const std::vector< uint8_t > & key_id ) const
overridevirtual

Find a certificate by Subject DN and (optionally) key identifier

Parameters
subject_dnthe subject's distinguished name
key_idan optional key id
Returns
a matching certificate or nullopt otherwise If more than one certificate in the certificate store matches, then a single value is selected arbitrarily.

Reimplemented from Botan::Certificate_Store.

Definition at line 34 of file certstor_system.cpp.

35 {
36 return m_system_store->find_cert(subject_dn, key_id);
37}

◆ find_cert_by_pubkey_sha1()

std::optional< X509_Certificate > Botan::System_Certificate_Store::find_cert_by_pubkey_sha1 ( const std::vector< uint8_t > & key_hash) const
overridevirtual

Find a certificate by searching for one with a matching SHA-1 hash of public key. Used for OCSP.

Parameters
key_hashSHA-1 hash of the subject's public key
Returns
a matching certificate or nullopt otherwise

Implements Botan::Certificate_Store.

Definition at line 44 of file certstor_system.cpp.

45 {
46 return m_system_store->find_cert_by_pubkey_sha1(key_hash);
47}

◆ find_cert_by_raw_subject_dn_sha256()

std::optional< X509_Certificate > Botan::System_Certificate_Store::find_cert_by_raw_subject_dn_sha256 ( const std::vector< uint8_t > & subject_hash) const
overridevirtual

Find a certificate by searching for one with a matching SHA-256 hash of raw subject name. Used for OCSP.

Parameters
subject_hashSHA-256 hash of the subject's raw name
Returns
a matching certificate or nullopt otherwise

Implements Botan::Certificate_Store.

Definition at line 49 of file certstor_system.cpp.

50 {
51 return m_system_store->find_cert_by_raw_subject_dn_sha256(subject_hash);
52}

◆ find_crl_for()

std::optional< X509_CRL > Botan::System_Certificate_Store::find_crl_for ( const X509_Certificate & subject) const
overridevirtual

Finds a CRL for the given certificate

Parameters
subjectthe subject certificate
Returns
the CRL for subject or nullopt otherwise

Reimplemented from Botan::Certificate_Store.

Definition at line 54 of file certstor_system.cpp.

54 {
55 return m_system_store->find_crl_for(subject);
56}

The documentation for this class was generated from the following files: