Botan 2.19.1
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< std::shared_ptr< const X509_Certificate > > find_all_certs (const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) const override
 
std::shared_ptr< const X509_Certificatefind_cert (const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) const override
 
std::shared_ptr< const X509_Certificatefind_cert_by_pubkey_sha1 (const std::vector< uint8_t > &key_hash) const override
 
std::shared_ptr< const X509_Certificatefind_cert_by_raw_subject_dn_sha256 (const std::vector< uint8_t > &subject_hash) const override
 
std::shared_ptr< const 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 21 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 }

Member Function Documentation

◆ all_subjects()

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

Implements Botan::Certificate_Store.

Definition at line 65 of file certstor_system.cpp.

66 {
67 return m_system_store->all_subjects();
68 }

◆ 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 72 of file certstor.h.

73 {
74 return find_cert(cert.subject_dn(), cert.subject_key_id()) != nullptr;
75 }
virtual std::shared_ptr< const 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< std::shared_ptr< const 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 41 of file certstor_system.cpp.

43 {
44 return m_system_store->find_all_certs(subject_dn, key_id);
45 }

◆ find_cert()

std::shared_ptr< const 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 nullptr 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 35 of file certstor_system.cpp.

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

◆ find_cert_by_pubkey_sha1()

std::shared_ptr< const 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 nullptr otherwise

Implements Botan::Certificate_Store.

Definition at line 48 of file certstor_system.cpp.

49 {
50 return m_system_store->find_cert_by_pubkey_sha1(key_hash);
51 }

◆ find_cert_by_raw_subject_dn_sha256()

std::shared_ptr< const 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 nullptr otherwise

Implements Botan::Certificate_Store.

Definition at line 54 of file certstor_system.cpp.

55 {
56 return m_system_store->find_cert_by_raw_subject_dn_sha256(subject_hash);
57 }

◆ find_crl_for()

std::shared_ptr< const 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 nullptr otherwise

Reimplemented from Botan::Certificate_Store.

Definition at line 60 of file certstor_system.cpp.

61 {
62 return m_system_store->find_crl_for(subject);
63 }

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