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 #include <vector> |
11 | 11 |
12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
13 #include "net/base/ssl_client_cert_type.h" | |
13 | 14 |
14 namespace net { | 15 namespace net { |
15 | 16 |
16 // An interface for storing and retrieving origin bound certs. Origin bound | 17 // An interface for storing and retrieving origin bound certs. Origin bound |
17 // certificates are specified in | 18 // certificates are specified in |
18 // http://balfanz.github.com/tls-obc-spec/draft-balfanz-tls-obc-00.html. | 19 // http://balfanz.github.com/tls-obc-spec/draft-balfanz-tls-obc-00.html. |
19 | 20 |
20 // Owned only by a single OriginBoundCertService object, which is responsible | 21 // Owned only by a single OriginBoundCertService object, which is responsible |
21 // for deleting it. | 22 // for deleting it. |
22 | 23 |
23 class NET_EXPORT OriginBoundCertStore { | 24 class NET_EXPORT OriginBoundCertStore { |
24 public: | 25 public: |
25 // Used by GetAllOriginBoundCerts. | 26 // The OriginBoundCert class contains a private key in addition to the origin |
26 struct OriginBoundCertInfo { | 27 // and the cert. |
wtc
2011/12/06 00:18:05
Nit: should we also mention the "type" field?
mattm
2011/12/06 00:54:01
Done.
| |
27 std::string origin; // Origin, for instance "https://www.verisign.com:443". | 28 class NET_EXPORT OriginBoundCert { |
28 std::string private_key; // DER-encoded PrivateKeyInfo struct. | 29 public: |
29 std::string cert; // DER-encoded certificate. | 30 OriginBoundCert(); |
31 OriginBoundCert(const std::string& origin, | |
32 SSLClientCertType type, | |
33 const std::string& privatekey, | |
wtc
2011/12/06 00:18:05
Nit: privatekey => private_key
mattm
2011/12/06 00:54:01
Done.
| |
34 const std::string& cert); | |
35 ~OriginBoundCert(); | |
36 | |
37 const std::string& origin() const { return origin_; } | |
38 SSLClientCertType type() const { return type_; } | |
39 const std::string& private_key() const { return private_key_; } | |
40 const std::string& cert() const { return cert_; } | |
41 | |
42 private: | |
43 std::string origin_; | |
44 SSLClientCertType type_; | |
45 std::string private_key_; | |
46 std::string cert_; | |
wtc
2011/12/06 00:18:05
Should we document these fields? See the original
mattm
2011/12/06 00:54:01
Done.
| |
30 }; | 47 }; |
31 | 48 |
32 virtual ~OriginBoundCertStore() {} | 49 virtual ~OriginBoundCertStore() {} |
33 | 50 |
34 // TODO(rkn): Specify certificate type (RSA or DSA). | |
35 // TODO(rkn): File I/O may be required, so this should have an asynchronous | 51 // TODO(rkn): File I/O may be required, so this should have an asynchronous |
36 // interface. | 52 // interface. |
37 // Returns true on success. |private_key_result| stores a DER-encoded | 53 // Returns true on success. |private_key_result| stores a DER-encoded |
38 // PrivateKeyInfo struct and |cert_result| stores a DER-encoded | 54 // PrivateKeyInfo struct and |cert_result| stores a DER-encoded |
39 // certificate. Returns false if no origin bound cert exists for the | 55 // certificate. Returns false if no origin bound cert exists for the |
40 // specified origin. | 56 // specified origin. |
41 virtual bool GetOriginBoundCert(const std::string& origin, | 57 virtual bool GetOriginBoundCert( |
42 std::string* private_key_result, | 58 const std::string& origin, |
43 std::string* cert_result) = 0; | 59 SSLClientCertType* type, |
60 std::string* private_key_result, | |
61 std::string* cert_result) = 0; | |
44 | 62 |
45 // Adds an origin bound cert and the corresponding private key to the store. | 63 // Adds an origin bound cert and the corresponding private key to the store. |
46 virtual void SetOriginBoundCert(const std::string& origin, | 64 virtual void SetOriginBoundCert( |
47 const std::string& private_key, | 65 const std::string& origin, |
48 const std::string& cert) = 0; | 66 SSLClientCertType type, |
67 const std::string& private_key, | |
68 const std::string& cert) = 0; | |
49 | 69 |
50 // Removes an origin bound cert and the corresponding private key from the | 70 // Removes an origin bound cert and the corresponding private key from the |
51 // store. | 71 // store. |
52 virtual void DeleteOriginBoundCert(const std::string& origin) = 0; | 72 virtual void DeleteOriginBoundCert(const std::string& origin) = 0; |
53 | 73 |
54 // Removes all origin bound certs and the corresponding private keys from | 74 // Removes all origin bound certs and the corresponding private keys from |
55 // the store. | 75 // the store. |
56 virtual void DeleteAll() = 0; | 76 virtual void DeleteAll() = 0; |
57 | 77 |
58 // Returns all origin bound certs and the corresponding private keys. | 78 // Returns all origin bound certs and the corresponding private keys. |
59 virtual void GetAllOriginBoundCerts( | 79 virtual void GetAllOriginBoundCerts( |
60 std::vector<OriginBoundCertInfo>* origin_bound_certs) = 0; | 80 std::vector<OriginBoundCert>* origin_bound_certs) = 0; |
61 | 81 |
62 // Returns the number of certs in the store. | 82 // Returns the number of certs in the store. |
63 // Public only for unit testing. | 83 // Public only for unit testing. |
64 virtual int GetCertCount() = 0; | 84 virtual int GetCertCount() = 0; |
65 }; | 85 }; |
66 | 86 |
67 } // namespace net | 87 } // namespace net |
68 | 88 |
69 #endif // NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ | 89 #endif // NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ |
OLD | NEW |