Botan 3.12.0
Crypto and TLS for C&
Botan::Certificate_Store Class Referenceabstract

#include <certstor.h>

Inheritance diagram for Botan::Certificate_Store:
Botan::Certificate_Store_In_Memory Botan::Certificate_Store_In_SQL Botan::Certificate_Store_MacOS Botan::Certificate_Store_Windows Botan::Flatfile_Certificate_Store Botan::System_Certificate_Store Botan::Certificate_Store_In_SQLite

Public Member Functions

virtual std::vector< X509_DNall_subjects () const =0
bool certificate_known (const X509_Certificate &cert) const
virtual bool contains (const X509_Certificate &cert) const
virtual std::vector< X509_Certificatefind_all_certs (const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) const =0
virtual std::optional< X509_Certificatefind_cert (const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) const
virtual std::optional< X509_Certificatefind_cert_by_issuer_dn_and_serial_number (const X509_DN &issuer_dn, std::span< const uint8_t > serial_number) const =0
virtual std::optional< X509_Certificatefind_cert_by_pubkey_sha1 (const std::vector< uint8_t > &key_hash) const =0
virtual std::optional< X509_Certificatefind_cert_by_raw_subject_dn_sha256 (const std::vector< uint8_t > &subject_hash) const =0
virtual std::optional< X509_CRLfind_crl_for (const X509_Certificate &subject) const
virtual ~Certificate_Store ()

Detailed Description

Certificate Store Interface

Definition at line 23 of file certstor.h.

Constructor & Destructor Documentation

◆ ~Certificate_Store()

Botan::Certificate_Store::~Certificate_Store ( )
virtualdefault

References find_cert().

Member Function Documentation

◆ all_subjects()

◆ certificate_known()

bool Botan::Certificate_Store::certificate_known ( const X509_Certificate & cert) const

Old version of contains

Definition at line 24 of file certstor.cpp.

24 {
25 return contains(cert);
26}
virtual bool contains(const X509_Certificate &cert) const
Definition certstor.cpp:28

References contains().

Referenced by find_cert_by_issuer_dn_and_serial_number().

◆ contains()

bool Botan::Certificate_Store::contains ( const X509_Certificate & cert) const
virtual
Returns
whether this certificate is contained within the store
Parameters
certcertificate to be searched

Default implementation uses find_all_certs

Reimplemented in Botan::Certificate_Store_In_Memory, Botan::Certificate_Store_In_SQL, Botan::Certificate_Store_Windows, Botan::Flatfile_Certificate_Store, and Botan::System_Certificate_Store.

Definition at line 28 of file certstor.cpp.

28 {
29 for(const auto& cert : find_all_certs(searching.subject_dn(), searching.subject_key_id())) {
30 if(cert == searching) {
31 return true;
32 }
33 }
34
35 return false;
36}
virtual std::vector< X509_Certificate > find_all_certs(const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) const =0

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

Referenced by certificate_known(), and find_cert_by_issuer_dn_and_serial_number().

◆ find_all_certs()

virtual std::vector< X509_Certificate > Botan::Certificate_Store::find_all_certs ( const X509_DN & subject_dn,
const std::vector< uint8_t > & key_id ) const
pure virtual

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

Implemented in Botan::Certificate_Store_In_Memory, Botan::Certificate_Store_In_SQL, Botan::Certificate_Store_MacOS, Botan::Certificate_Store_Windows, Botan::Flatfile_Certificate_Store, and Botan::System_Certificate_Store.

Referenced by contains(), and find_cert().

◆ find_cert()

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

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 in Botan::Certificate_Store_In_Memory, Botan::Certificate_Store_In_SQL, Botan::Certificate_Store_MacOS, Botan::Certificate_Store_Windows, and Botan::System_Certificate_Store.

Definition at line 38 of file certstor.cpp.

39 {
40 const auto certs = find_all_certs(subject_dn, key_id);
41
42 if(certs.empty()) {
43 return std::nullopt;
44 }
45
46 // `count` might be greater than 1, but we'll just select the first match
47 return certs.front();
48}

References find_all_certs().

Referenced by Botan::OCSP::Response::find_signing_certificate(), and ~Certificate_Store().

◆ find_cert_by_issuer_dn_and_serial_number()

virtual std::optional< X509_Certificate > Botan::Certificate_Store::find_cert_by_issuer_dn_and_serial_number ( const X509_DN & issuer_dn,
std::span< const uint8_t > serial_number ) const
pure virtual

Find a certificate by searching for one with a matching issuer DN and serial number. Used for CMS or PKCS#7.

Parameters
issuer_dnthe distinguished name of the issuer
serial_numberthe certificate's serial number
Returns
a matching certificate or nullopt otherwise

Implemented in Botan::Certificate_Store_In_Memory, Botan::Certificate_Store_In_SQL, Botan::Certificate_Store_MacOS, Botan::Certificate_Store_Windows, Botan::Flatfile_Certificate_Store, and Botan::System_Certificate_Store.

References certificate_known(), contains(), and find_crl_for().

◆ find_cert_by_pubkey_sha1()

virtual std::optional< X509_Certificate > Botan::Certificate_Store::find_cert_by_pubkey_sha1 ( const std::vector< uint8_t > & key_hash) const
pure virtual

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

Implemented in Botan::Certificate_Store_In_Memory, Botan::Certificate_Store_In_SQL, Botan::Certificate_Store_MacOS, Botan::Certificate_Store_Windows, Botan::Flatfile_Certificate_Store, and Botan::System_Certificate_Store.

Referenced by Botan::OCSP::Response::find_signing_certificate().

◆ find_cert_by_raw_subject_dn_sha256()

virtual std::optional< X509_Certificate > Botan::Certificate_Store::find_cert_by_raw_subject_dn_sha256 ( const std::vector< uint8_t > & subject_hash) const
pure virtual

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

Implemented in Botan::Certificate_Store_In_Memory, Botan::Certificate_Store_In_SQL, Botan::Certificate_Store_MacOS, Botan::Certificate_Store_Windows, Botan::Flatfile_Certificate_Store, and Botan::System_Certificate_Store.

◆ find_crl_for()

std::optional< X509_CRL > Botan::Certificate_Store::find_crl_for ( const X509_Certificate & subject) const
virtual

Finds a CRL for the given certificate

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

Reimplemented in Botan::Certificate_Store_In_Memory, Botan::Certificate_Store_In_SQL, Botan::Certificate_Store_MacOS, Botan::Certificate_Store_Windows, Botan::Flatfile_Certificate_Store, and Botan::System_Certificate_Store.

Definition at line 50 of file certstor.cpp.

50 {
51 return std::nullopt;
52}

Referenced by find_cert_by_issuer_dn_and_serial_number().


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