OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_SSL_CLIENT_KEY_STORE_H_ | 5 #ifndef NET_SSL_CLIENT_KEY_STORE_H_ |
6 #define NET_SSL_CLIENT_KEY_STORE_H_ | 6 #define NET_SSL_CLIENT_KEY_STORE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 public: | 30 public: |
31 // This can be called from any thread. | 31 // This can be called from any thread. |
32 virtual ~CertKeyProvider() {} | 32 virtual ~CertKeyProvider() {} |
33 | 33 |
34 // Obtains a handle to the certificate private key for |cert| and stores it | 34 // Obtains a handle to the certificate private key for |cert| and stores it |
35 // in |private_key|. | 35 // in |private_key|. |
36 // If the CertKeyProvider does not know about the |cert|, returns false. If | 36 // If the CertKeyProvider does not know about the |cert|, returns false. If |
37 // it knows about the certificate, but is unable to return the private key, | 37 // it knows about the certificate, but is unable to return the private key, |
38 // returns true and sets |*private_key| to nullptr. | 38 // returns true and sets |*private_key| to nullptr. |
39 // This can be called from any thread. | 39 // This can be called from any thread. |
40 virtual bool GetCertificateKey(const X509Certificate& cert, | 40 virtual bool GetCertificateKey( |
41 scoped_ptr<SSLPrivateKey>* private_key) = 0; | 41 const X509Certificate& cert, |
| 42 scoped_refptr<SSLPrivateKey>* private_key) = 0; |
42 }; | 43 }; |
43 | 44 |
44 static ClientKeyStore* GetInstance(); | 45 static ClientKeyStore* GetInstance(); |
45 | 46 |
46 // The |provider| will be accessed on any thread but no concurrent method | 47 // The |provider| will be accessed on any thread but no concurrent method |
47 // invocations will happen. |provider| must be valid until it is removed using | 48 // invocations will happen. |provider| must be valid until it is removed using |
48 // |RemoveProvider| or the store is destroyed. | 49 // |RemoveProvider| or the store is destroyed. |
49 void AddProvider(CertKeyProvider* provider); | 50 void AddProvider(CertKeyProvider* provider); |
50 | 51 |
51 void RemoveProvider(const CertKeyProvider* provider); | 52 void RemoveProvider(const CertKeyProvider* provider); |
52 | 53 |
53 // Given a |certificate|'s public key, return the corresponding private | 54 // Given a |certificate|'s public key, return the corresponding private |
54 // key if any of the registered providers has a matching key. | 55 // key if any of the registered providers has a matching key. |
55 // Returns its matching private key on success, nullptr otherwise. | 56 // Returns its matching private key on success, nullptr otherwise. |
56 scoped_ptr<SSLPrivateKey> FetchClientCertPrivateKey( | 57 scoped_refptr<SSLPrivateKey> FetchClientCertPrivateKey( |
57 const X509Certificate& certificate); | 58 const X509Certificate& certificate); |
58 | 59 |
59 private: | 60 private: |
60 friend struct base::DefaultLazyInstanceTraits<ClientKeyStore>; | 61 friend struct base::DefaultLazyInstanceTraits<ClientKeyStore>; |
61 | 62 |
62 ClientKeyStore(); | 63 ClientKeyStore(); |
63 ~ClientKeyStore(); | 64 ~ClientKeyStore(); |
64 | 65 |
65 base::Lock lock_; | 66 base::Lock lock_; |
66 std::vector<CertKeyProvider*> providers_; | 67 std::vector<CertKeyProvider*> providers_; |
67 | 68 |
68 DISALLOW_COPY_AND_ASSIGN(ClientKeyStore); | 69 DISALLOW_COPY_AND_ASSIGN(ClientKeyStore); |
69 }; | 70 }; |
70 | 71 |
71 } // namespace net | 72 } // namespace net |
72 | 73 |
73 #endif // NET_SSL_CLIENT_KEY_STORE_H_ | 74 #endif // NET_SSL_CLIENT_KEY_STORE_H_ |
OLD | NEW |