1 // Copyright 2016 The Chromium Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef BSSL_PKI_TRUST_STORE_COLLECTION_H_
16 #define BSSL_PKI_TRUST_STORE_COLLECTION_H_
17 
18 #include <openssl/base.h>
19 
20 #include "trust_store.h"
21 
22 BSSL_NAMESPACE_BEGIN
23 
24 // TrustStoreCollection is an implementation of TrustStore which combines the
25 // results from multiple TrustStores.
26 //
27 // The order of the matches will correspond to a concatenation of matches in
28 // the order the stores were added.
29 class OPENSSL_EXPORT TrustStoreCollection : public TrustStore {
30  public:
31   TrustStoreCollection();
32 
33   TrustStoreCollection(const TrustStoreCollection &) = delete;
34   TrustStoreCollection &operator=(const TrustStoreCollection &) = delete;
35 
36   ~TrustStoreCollection() override;
37 
38   // Includes results from |store| in the combined output. |store| must
39   // outlive the TrustStoreCollection.
40   void AddTrustStore(TrustStore *store);
41 
42   // TrustStore implementation:
43   void SyncGetIssuersOf(const ParsedCertificate *cert,
44                         ParsedCertificateList *issuers) override;
45   CertificateTrust GetTrust(const ParsedCertificate *cert) override;
46 
47  private:
48   std::vector<TrustStore *> stores_;
49 };
50 
51 BSSL_NAMESPACE_END
52 
53 #endif  // BSSL_PKI_TRUST_STORE_COLLECTION_H_
54