OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ | 5 #ifndef NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ |
6 #define NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ | 6 #define NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | |
10 | 11 |
11 #include "net/base/net_api.h" | 12 #include "net/base/net_api.h" |
12 | 13 |
13 namespace net { | 14 namespace net { |
14 | 15 |
15 // An interface for storing and retrieving origin bound certs. Origin bound | 16 // An interface for storing and retrieving origin bound certs. Origin bound |
16 // certificates are specified in | 17 // certificates are specified in |
17 // http://balfanz.github.com/tls-obc-spec/draft-balfanz-tls-obc-00.html. | 18 // http://balfanz.github.com/tls-obc-spec/draft-balfanz-tls-obc-00.html. |
18 | 19 |
19 // Owned only by a single OriginBoundCertService object, which is responsible | 20 // Owned only by a single OriginBoundCertService object, which is responsible |
20 // for deleting it. | 21 // for deleting it. |
21 | 22 |
22 class NET_API OriginBoundCertStore { | 23 class NET_API OriginBoundCertStore { |
23 public: | 24 public: |
25 struct OriginBoundCertInfo { | |
wtc
2011/08/16 23:28:57
Should we mention this is used by GetAllOriginBoun
| |
26 std::string origin; // Origin, for instance "https://www.versign.com:8443". | |
wtc
2011/08/16 23:28:57
Nit: "versign" is misspelled. Use a typical HTTPS
| |
27 std::string private_key; // DER-encoded PrivateKeyInfo struct. | |
28 std::string cert; // DER-encoded certificate. | |
29 }; | |
30 | |
24 virtual ~OriginBoundCertStore() {} | 31 virtual ~OriginBoundCertStore() {} |
25 | 32 |
26 // TODO(rkn): Specify certificate type (RSA or DSA). | 33 // TODO(rkn): Specify certificate type (RSA or DSA). |
27 // TODO(rkn): File I/O may be required, so this should have an asynchronous | 34 // TODO(rkn): File I/O may be required, so this should have an asynchronous |
28 // interface. | 35 // interface. |
29 // Returns true on success. |private_key_result| stores a DER-encoded | 36 // Returns true on success. |private_key_result| stores a DER-encoded |
30 // PrivateKeyInfo struct and |cert_result| stores a DER-encoded | 37 // PrivateKeyInfo struct and |cert_result| stores a DER-encoded |
31 // certificate. Returns false if no origin bound cert exists for the | 38 // certificate. Returns false if no origin bound cert exists for the |
32 // specified origin. | 39 // specified origin. |
33 virtual bool GetOriginBoundCert(const std::string& origin, | 40 virtual bool GetOriginBoundCert(const std::string& origin, |
34 std::string* private_key_result, | 41 std::string* private_key_result, |
35 std::string* cert_result) = 0; | 42 std::string* cert_result) = 0; |
36 | 43 |
37 // Adds an origin bound cert to the store. | 44 // Adds an origin bound cert and the corresponding private key to the store. |
38 virtual bool SetOriginBoundCert(const std::string& origin, | 45 virtual void SetOriginBoundCert(const std::string& origin, |
39 const std::string& private_key, | 46 const std::string& private_key, |
40 const std::string& cert) = 0; | 47 const std::string& cert) = 0; |
41 | 48 |
49 // Removes an origin bound cert and the corresponding private key from the | |
50 // store. | |
51 virtual void DeleteOriginBoundCert(const std::string& origin) = 0; | |
52 | |
53 // Removes all origin bound certs and the corresponding private keys from | |
54 // the store. | |
55 virtual void DeleteAll() = 0; | |
56 | |
57 // Returns all origin bound certs and the corresponding private keys. | |
58 virtual void GetAllOriginBoundCerts( | |
59 std::vector<OriginBoundCertInfo>* origin_bound_certs) = 0; | |
60 | |
42 // Returns the number of certs in the store. | 61 // Returns the number of certs in the store. |
43 // Public only for unit testing. | 62 // Public only for unit testing. |
44 virtual int GetCertCount() = 0; | 63 virtual int GetCertCount() = 0; |
45 }; | 64 }; |
46 | 65 |
47 } // namespace net | 66 } // namespace net |
48 | 67 |
49 #endif // NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ | 68 #endif // NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ |
OLD | NEW |