Botan 3.6.1
Crypto and TLS for C&
|
#include <certstor_sql.h>
Public Member Functions | |
void | affirm_cert (const X509_Certificate &) |
Reverses the revokation for "cert". | |
std::vector< X509_DN > | all_subjects () const override |
bool | certificate_known (const X509_Certificate &cert) const |
Certificate_Store_In_SQL (std::shared_ptr< SQL_Database > db, std::string_view passwd, RandomNumberGenerator &rng, std::string_view table_prefix="") | |
std::vector< X509_Certificate > | find_all_certs (const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) const override |
std::optional< X509_Certificate > | find_cert (const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) 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_by_raw_subject_dn_sha256 (const std::vector< uint8_t > &subject_hash) const override |
std::vector< X509_Certificate > | find_certs_for_key (const Private_Key &key) const |
Returns all certificates for private key "key". | |
std::optional< X509_CRL > | find_crl_for (const X509_Certificate &issuer) const override |
std::shared_ptr< const Private_Key > | find_key (const X509_Certificate &) const |
Returns the private key for "cert" or an empty shared_ptr if none was found. | |
std::vector< X509_CRL > | generate_crls () const |
bool | insert_cert (const X509_Certificate &cert) |
bool | insert_key (const X509_Certificate &cert, const Private_Key &key) |
bool | remove_cert (const X509_Certificate &cert) |
void | remove_key (const Private_Key &key) |
Removes "key" from the store. | |
void | revoke_cert (const X509_Certificate &, CRL_Code, const X509_Time &time=X509_Time()) |
Marks "cert" as revoked starting from "time". | |
Certificate and private key store backed by an SQL database.
Definition at line 24 of file certstor_sql.h.
|
explicit |
Create/open a certificate store.
db | underlying database storage |
passwd | password to encrypt private keys in the database |
rng | used for encrypting keys |
table_prefix | optional prefix for db table names |
Definition at line 19 of file certstor_sql.cpp.
void Botan::Certificate_Store_In_SQL::affirm_cert | ( | const X509_Certificate & | cert | ) |
Reverses the revokation for "cert".
Definition at line 266 of file certstor_sql.cpp.
References Botan::X509_Certificate::fingerprint().
|
overridevirtual |
Returns all subject DNs known to the store instance.
Implements Botan::Certificate_Store.
Definition at line 122 of file certstor_sql.cpp.
References Botan::X509_DN::decode_from().
|
inlineinherited |
cert | certififcate to be searched |
Definition at line 70 of file certstor.h.
References Botan::X509_Certificate::subject_dn(), and Botan::X509_Certificate::subject_key_id().
|
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 72 of file certstor_sql.cpp.
References Botan::ASN1_Object::BER_encode().
|
overridevirtual |
Returns the first certificate with matching subject DN and optional key ID.
Reimplemented from Botan::Certificate_Store.
Definition at line 46 of file certstor_sql.cpp.
References Botan::ASN1_Object::BER_encode().
Referenced by remove_cert().
|
overridevirtual |
Find a certificate by searching for one with a matching SHA-1 hash of public key. Used for OCSP.
key_hash | SHA-1 hash of the subject's public key |
Implements Botan::Certificate_Store.
Definition at line 100 of file certstor_sql.cpp.
|
overridevirtual |
Find a certificate by searching for one with a matching SHA-256 hash of raw subject name. Used for OCSP.
subject_hash | SHA-256 hash of the subject's raw name |
Implements Botan::Certificate_Store.
Definition at line 105 of file certstor_sql.cpp.
std::vector< X509_Certificate > Botan::Certificate_Store_In_SQL::find_certs_for_key | ( | const Private_Key & | key | ) | const |
Returns all certificates for private key "key".
Definition at line 196 of file certstor_sql.cpp.
References Botan::Private_Key::fingerprint_private().
|
overridevirtual |
Generates a CRL for all certificates issued by the given issuer.
Reimplemented from Botan::Certificate_Store.
Definition at line 110 of file certstor_sql.cpp.
References generate_crls(), and Botan::X509_Certificate::issuer_dn().
std::shared_ptr< const Private_Key > Botan::Certificate_Store_In_SQL::find_key | ( | const X509_Certificate & | cert | ) | const |
Returns the private key for "cert" or an empty shared_ptr if none was found.
Definition at line 176 of file certstor_sql.cpp.
References Botan::X509_Certificate::fingerprint(), and Botan::PKCS8::load_key().
Referenced by insert_key().
std::vector< X509_CRL > Botan::Certificate_Store_In_SQL::generate_crls | ( | ) | const |
Generates Certificate Revocation Lists for all certificates marked as revoked. A CRL is returned for each unique issuer DN.
Definition at line 273 of file certstor_sql.cpp.
Referenced by find_crl_for().
bool Botan::Certificate_Store_In_SQL::insert_cert | ( | const X509_Certificate & | cert | ) |
Inserts "cert" into the store, returns false if the certificate is already known and true if insertion was successful.
Definition at line 139 of file certstor_sql.cpp.
References Botan::ASN1_Object::BER_encode(), Botan::X509_Certificate::fingerprint(), Botan::X509_Certificate::subject_dn(), and Botan::X509_Certificate::subject_key_id().
Referenced by insert_key(), and revoke_cert().
bool Botan::Certificate_Store_In_SQL::insert_key | ( | const X509_Certificate & | cert, |
const Private_Key & | key ) |
Inserts "key" for "cert" into the store, returns false if the key is already known and true if insertion was successful.
Definition at line 212 of file certstor_sql.cpp.
References Botan::PKCS8::BER_encode(), find_key(), Botan::X509_Certificate::fingerprint(), Botan::Private_Key::fingerprint_private(), and insert_cert().
bool Botan::Certificate_Store_In_SQL::remove_cert | ( | const X509_Certificate & | cert | ) |
Removes "cert" from the store. Returns false if the certificate could not be found and true if removal was successful.
Definition at line 162 of file certstor_sql.cpp.
References find_cert(), Botan::X509_Certificate::fingerprint(), Botan::X509_Certificate::subject_dn(), and Botan::X509_Certificate::subject_key_id().
void Botan::Certificate_Store_In_SQL::remove_key | ( | const Private_Key & | key | ) |
Removes "key" from the store.
Definition at line 239 of file certstor_sql.cpp.
References Botan::Private_Key::fingerprint_private().
void Botan::Certificate_Store_In_SQL::revoke_cert | ( | const X509_Certificate & | cert, |
CRL_Code | code, | ||
const X509_Time & | time = X509_Time() ) |
Marks "cert" as revoked starting from "time".
Definition at line 248 of file certstor_sql.cpp.
References Botan::ASN1_Object::BER_encode(), Botan::X509_Certificate::fingerprint(), insert_cert(), and Botan::ASN1_Time::time_is_set().