|
Botan 3.12.0
Crypto and TLS for C&
|
#include <x509_cert_cache.h>
Public Member Functions | |
| X509_Certificate | find_or_insert (std::span< const uint8_t > encoding) |
| X509_Certificate_Cache (size_t max_entries=64) | |
A cache for X.509 certificates
This is primarily useful for system certificate stores (Windows, macOS) where repeated lookups via native APIs return raw DER bytes that must be parsed each time. The cache deduplicates these by keying on the SHA-256 hash of the DER encoding.
Definition at line 30 of file x509_cert_cache.h.
|
explicit |
| max_entries | maximum number of certificates to cache. When the cache is full, an entry is evicted to make room. If 0, caching is disabled entirely. |
Definition at line 13 of file x509_cert_cache.cpp.
| X509_Certificate Botan::X509_Certificate_Cache::find_or_insert | ( | std::span< const uint8_t > | encoding | ) |
Look up a certificate by its DER encoding, or parse and cache it.
If a certificate with the same DER encoding (by SHA-256 hash) is already in the cache, returns a (cheap, shared_ptr-backed) copy. Otherwise, parses the DER encoding into an X509_Certificate, inserts it into the cache, and returns it.
If the cache was constructed with max_entries == 0, always parses and never caches.
| encoding | DER-encoded certificate |
| Decoding_Error | if the encoding is not a valid certificate |
Definition at line 15 of file x509_cert_cache.cpp.
References Botan::HashFunction::create_or_throw(), and Botan::lock().