Botan
1.11.15
|
#include <certstor.h>
Public Member Functions | |
void | add_certificate (const X509_Certificate &cert) |
void | add_crl (const X509_CRL &crl) |
std::vector< X509_DN > | all_subjects () const override |
bool | certificate_known (const X509_Certificate &cert) const |
Certificate_Store_In_Memory (const std::string &dir) | |
Certificate_Store_In_Memory () | |
const X509_Certificate * | find_cert (const X509_DN &subject_dn, const std::vector< byte > &key_id) const override |
const X509_CRL * | find_crl_for (const X509_Certificate &subject) const override |
In Memory Certificate Store
Definition at line 44 of file certstor.h.
Botan::Certificate_Store_In_Memory::Certificate_Store_In_Memory | ( | const std::string & | dir | ) |
Attempt to parse all files in dir (including subdirectories) as certificates. Ignores errors.
Definition at line 111 of file certstor.cpp.
References Botan::list_all_readable_files_in_or_under().
{ if(dir == "") return; std::vector<std::string> maybe_certs = list_all_readable_files_in_or_under(dir); for(auto&& cert_file : maybe_certs) { try { m_certs.push_back(X509_Certificate(cert_file)); } catch(std::exception&) { } } }
Definition at line 53 of file certstor.h.
{}
void Botan::Certificate_Store_In_Memory::add_certificate | ( | const X509_Certificate & | cert | ) |
Definition at line 18 of file certstor.cpp.
{ for(size_t i = 0; i != m_certs.size(); ++i) { if(m_certs[i] == cert) return; } m_certs.push_back(cert); }
void Botan::Certificate_Store_In_Memory::add_crl | ( | const X509_CRL & | crl | ) |
Definition at line 70 of file certstor.cpp.
References Botan::X509_CRL::issuer_dn(), and Botan::X509_CRL::this_update().
{ X509_DN crl_issuer = crl.issuer_dn(); for(size_t i = 0; i != m_crls.size(); ++i) { // Found an update of a previously existing one; replace it if(m_crls[i].issuer_dn() == crl_issuer) { if(m_crls[i].this_update() <= crl.this_update()) m_crls[i] = crl; return; } } // Totally new CRL, add to the list m_crls.push_back(crl); }
std::vector< X509_DN > Botan::Certificate_Store_In_Memory::all_subjects | ( | ) | const [override, virtual] |
Implements Botan::Certificate_Store.
Definition at line 29 of file certstor.cpp.
{ std::vector<X509_DN> subjects; for(size_t i = 0; i != m_certs.size(); ++i) subjects.push_back(m_certs[i].subject_dn()); return subjects; }
bool Botan::Certificate_Store::certificate_known | ( | const X509_Certificate & | cert | ) | const [inline, inherited] |
Definition at line 32 of file certstor.h.
References Botan::X509_Certificate::subject_dn(), and Botan::X509_Certificate::subject_key_id().
{ return find_cert(cert.subject_dn(), cert.subject_key_id()) != nullptr; }
const X509_Certificate * Botan::Certificate_Store_In_Memory::find_cert | ( | const X509_DN & | subject_dn, |
const std::vector< byte > & | key_id | ||
) | const [override, virtual] |
Subject DN and (optionally) key identifier
Implements Botan::Certificate_Store.
Definition at line 64 of file certstor.cpp.
{
return cert_search(subject_dn, key_id, m_certs);
}
const X509_CRL * Botan::Certificate_Store_In_Memory::find_crl_for | ( | const X509_Certificate & | subject | ) | const [override, virtual] |
Reimplemented from Botan::Certificate_Store.
Definition at line 89 of file certstor.cpp.
References Botan::X509_Certificate::authority_key_id(), and Botan::X509_Certificate::issuer_dn().
{ const std::vector<byte>& key_id = subject.authority_key_id(); for(size_t i = 0; i != m_crls.size(); ++i) { // Only compare key ids if set in both call and in the CRL if(key_id.size()) { std::vector<byte> akid = m_crls[i].authority_key_id(); if(akid.size() && akid != key_id) // no match continue; } if(m_crls[i].issuer_dn() == subject.issuer_dn()) return &m_crls[i]; } return nullptr; }