1 // Copyright 2016 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BSSL_PKI_CERT_ISSUER_SOURCE_STATIC_H_ 6 #define BSSL_PKI_CERT_ISSUER_SOURCE_STATIC_H_ 7 8 #include <unordered_map> 9 10 #include <openssl/base.h> 11 12 #include "cert_issuer_source.h" 13 14 namespace bssl { 15 16 // Synchronously returns issuers from a pre-supplied set. 17 class OPENSSL_EXPORT CertIssuerSourceStatic : public CertIssuerSource { 18 public: 19 CertIssuerSourceStatic(); 20 21 CertIssuerSourceStatic(const CertIssuerSourceStatic &) = delete; 22 CertIssuerSourceStatic &operator=(const CertIssuerSourceStatic &) = delete; 23 24 ~CertIssuerSourceStatic() override; 25 26 // Adds |cert| to the set of certificates that this CertIssuerSource will 27 // provide. 28 void AddCert(std::shared_ptr<const ParsedCertificate> cert); 29 30 // Clears the set of certificates. 31 void Clear(); 32 size()33 size_t size() const { return intermediates_.size(); } 34 35 // CertIssuerSource implementation: 36 void SyncGetIssuersOf(const ParsedCertificate *cert, 37 ParsedCertificateList *issuers) override; 38 void AsyncGetIssuersOf(const ParsedCertificate *cert, 39 std::unique_ptr<Request> *out_req) override; 40 41 private: 42 // The certificates that the CertIssuerSourceStatic can return, keyed on the 43 // normalized subject value. 44 std::unordered_multimap<std::string_view, 45 std::shared_ptr<const ParsedCertificate>> 46 intermediates_; 47 }; 48 49 } // namespace bssl 50 51 #endif // BSSL_PKI_CERT_ISSUER_SOURCE_STATIC_H_ 52