Chromium Code Reviews| 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 not_valid_after, | |
|
wtc
2011/12/14 02:03:39
Nit: "expiration_time" or "expiry_time" may be eas
mattm
2011/12/20 00:28:38
Done.
| |
| 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 base::Time not_valid_after() const { return not_valid_after_; } | |
|
wtc
2011/12/14 02:03:39
Please document this getter method.
mattm
2011/12/20 00:28:38
Done.
| |
| 41 // The encoding of the private key depends on the type. | 44 // The encoding of the private key depends on the type. |
| 42 // rsa_sign: DER-encoded PrivateKeyInfo struct. | 45 // rsa_sign: DER-encoded PrivateKeyInfo struct. |
| 43 // ecdsa_sign: DER-encoded EncryptedPrivateKeyInfo struct. | 46 // ecdsa_sign: DER-encoded EncryptedPrivateKeyInfo struct. |
| 44 const std::string& private_key() const { return private_key_; } | 47 const std::string& private_key() const { return private_key_; } |
| 45 // DER-encoded certificate. | 48 // DER-encoded certificate. |
| 46 const std::string& cert() const { return cert_; } | 49 const std::string& cert() const { return cert_; } |
| 47 | 50 |
| 48 private: | 51 private: |
| 49 std::string origin_; | 52 std::string origin_; |
| 50 SSLClientCertType type_; | 53 SSLClientCertType type_; |
| 54 base::Time not_valid_after_; | |
| 51 std::string private_key_; | 55 std::string private_key_; |
| 52 std::string cert_; | 56 std::string cert_; |
| 53 }; | 57 }; |
| 54 | 58 |
| 55 virtual ~OriginBoundCertStore() {} | 59 virtual ~OriginBoundCertStore() {} |
| 56 | 60 |
| 57 // TODO(rkn): File I/O may be required, so this should have an asynchronous | 61 // TODO(rkn): File I/O may be required, so this should have an asynchronous |
| 58 // interface. | 62 // interface. |
| 59 // Returns true on success. |private_key_result| stores a DER-encoded | 63 // Returns true on success. |private_key_result| stores a DER-encoded |
| 60 // PrivateKeyInfo struct and |cert_result| stores a DER-encoded | 64 // PrivateKeyInfo struct and |cert_result| stores a DER-encoded |
| 61 // certificate. Returns false if no origin bound cert exists for the | 65 // certificate. Returns false if no origin bound cert exists for the |
| 62 // specified origin. | 66 // specified origin. |
| 63 virtual bool GetOriginBoundCert( | 67 virtual bool GetOriginBoundCert( |
| 64 const std::string& origin, | 68 const std::string& origin, |
| 65 SSLClientCertType* type, | 69 SSLClientCertType* type, |
| 70 base::Time* not_valid_after, | |
|
wtc
2011/12/14 02:03:39
Please document the |type| and |not_valid_after| o
mattm
2011/12/20 00:28:38
Done.
| |
| 66 std::string* private_key_result, | 71 std::string* private_key_result, |
| 67 std::string* cert_result) = 0; | 72 std::string* cert_result) = 0; |
| 68 | 73 |
| 69 // Adds an origin bound cert and the corresponding private key to the store. | 74 // Adds an origin bound cert and the corresponding private key to the store. |
| 70 virtual void SetOriginBoundCert( | 75 virtual void SetOriginBoundCert( |
| 71 const std::string& origin, | 76 const std::string& origin, |
| 72 SSLClientCertType type, | 77 SSLClientCertType type, |
| 78 base::Time not_valid_after, | |
| 73 const std::string& private_key, | 79 const std::string& private_key, |
| 74 const std::string& cert) = 0; | 80 const std::string& cert) = 0; |
| 75 | 81 |
| 76 // Removes an origin bound cert and the corresponding private key from the | 82 // Removes an origin bound cert and the corresponding private key from the |
| 77 // store. | 83 // store. |
| 78 virtual void DeleteOriginBoundCert(const std::string& origin) = 0; | 84 virtual void DeleteOriginBoundCert(const std::string& origin) = 0; |
| 79 | 85 |
| 80 // Removes all origin bound certs and the corresponding private keys from | 86 // Removes all origin bound certs and the corresponding private keys from |
| 81 // the store. | 87 // the store. |
| 82 virtual void DeleteAll() = 0; | 88 virtual void DeleteAll() = 0; |
| 83 | 89 |
| 84 // Returns all origin bound certs and the corresponding private keys. | 90 // Returns all origin bound certs and the corresponding private keys. |
| 85 virtual void GetAllOriginBoundCerts( | 91 virtual void GetAllOriginBoundCerts( |
| 86 std::vector<OriginBoundCert>* origin_bound_certs) = 0; | 92 std::vector<OriginBoundCert>* origin_bound_certs) = 0; |
| 87 | 93 |
| 88 // Returns the number of certs in the store. | 94 // Returns the number of certs in the store. |
| 89 // Public only for unit testing. | 95 // Public only for unit testing. |
| 90 virtual int GetCertCount() = 0; | 96 virtual int GetCertCount() = 0; |
| 91 }; | 97 }; |
| 92 | 98 |
| 93 } // namespace net | 99 } // namespace net |
| 94 | 100 |
| 95 #endif // NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ | 101 #endif // NET_BASE_ORIGIN_BOUND_CERT_STORE_H_ |
| OLD | NEW |