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