blob: 1e60934449ec8f5ce75c62bb1164d3f234ad59dc [file] [log] [blame]
Bob Beckbc97b7a2023-04-18 08:35:15 -06001// 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
Bob Beckbc97b7a2023-04-18 08:35:15 -06008#include <unordered_map>
9
Bob Beck3cd30cc2023-11-22 16:59:00 -070010#include <openssl/base.h>
Bob Beckbc97b7a2023-04-18 08:35:15 -060011
12#include "cert_issuer_source.h"
13
14namespace bssl {
15
16// Synchronously returns issuers from a pre-supplied set.
17class OPENSSL_EXPORT CertIssuerSourceStatic : public CertIssuerSource {
18 public:
19 CertIssuerSourceStatic();
20
Bob Beck5c7a2a02023-11-20 17:28:21 -070021 CertIssuerSourceStatic(const CertIssuerSourceStatic &) = delete;
22 CertIssuerSourceStatic &operator=(const CertIssuerSourceStatic &) = delete;
Bob Beckbc97b7a2023-04-18 08:35:15 -060023
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
33 size_t size() const { return intermediates_.size(); }
34
35 // CertIssuerSource implementation:
Bob Beck5c7a2a02023-11-20 17:28:21 -070036 void SyncGetIssuersOf(const ParsedCertificate *cert,
37 ParsedCertificateList *issuers) override;
38 void AsyncGetIssuersOf(const ParsedCertificate *cert,
39 std::unique_ptr<Request> *out_req) override;
Bob Beckbc97b7a2023-04-18 08:35:15 -060040
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
Bob Beck5c7a2a02023-11-20 17:28:21 -070049} // namespace bssl
Bob Beckbc97b7a2023-04-18 08:35:15 -060050
51#endif // BSSL_PKI_CERT_ISSUER_SOURCE_STATIC_H_