• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 NET_CERT_PKI_CERT_ISSUER_SOURCE_H_
6 #define NET_CERT_PKI_CERT_ISSUER_SOURCE_H_
7 
8 #include <memory>
9 #include <vector>
10 
11 #include "net/base/net_export.h"
12 #include "net/cert/pki/parsed_certificate.h"
13 
14 namespace net {
15 
16 // Interface for looking up issuers of a certificate during path building.
17 // Provides a synchronous and asynchronous method for retrieving issuers, so the
18 // path builder can try to complete synchronously first. The caller is expected
19 // to call SyncGetIssuersOf first, see if it can make progress with those
20 // results, and if not, then fall back to calling AsyncGetIssuersOf.
21 // An implementations may choose to return results from either one of the Get
22 // methods, or from both.
23 class NET_EXPORT CertIssuerSource {
24  public:
25   class NET_EXPORT Request {
26    public:
27     Request() = default;
28 
29     Request(const Request&) = delete;
30     Request& operator=(const Request&) = delete;
31 
32     // Destruction of the Request cancels it.
33     virtual ~Request() = default;
34 
35     // Retrieves issuers and appends them to |issuers|.
36     //
37     // GetNext should be called again to retrieve any remaining issuers.
38     //
39     // If no issuers are left then |issuers| will not be modified. This
40     // indicates that the issuers have been exhausted and GetNext() should
41     // not be called again.
42     virtual void GetNext(ParsedCertificateList* issuers) = 0;
43   };
44 
45   virtual ~CertIssuerSource() = default;
46 
47   // Finds certificates whose Subject matches |cert|'s Issuer.
48   // Matches are appended to |issuers|. Any existing contents of |issuers| will
49   // not be modified. If the implementation does not support synchronous
50   // lookups, or if there are no matches, |issuers| is not modified.
51   virtual void SyncGetIssuersOf(const ParsedCertificate* cert,
52                                 ParsedCertificateList* issuers) = 0;
53 
54   // Finds certificates whose Subject matches |cert|'s Issuer.
55   // If the implementation does not support asynchronous lookups or can
56   // determine synchronously that it would return no results, |*out_req|
57   // will be set to nullptr.
58   //
59   // Otherwise a request is started and saved to |out_req|. The results can be
60   // read through the Request interface.
61   virtual void AsyncGetIssuersOf(const ParsedCertificate* cert,
62                                  std::unique_ptr<Request>* out_req) = 0;
63 };
64 
65 }  // namespace net
66 
67 #endif  // NET_CERT_PKI_CERT_ISSUER_SOURCE_H_
68