OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CERT_STORE_NSS_H_ | 5 #ifndef NET_SSL_CLIENT_CERT_STORE_NSS_H_ |
6 #define NET_SSL_CLIENT_CERT_STORE_NSS_H_ | 6 #define NET_SSL_CLIENT_CERT_STORE_NSS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
12 #include "net/ssl/client_cert_store.h" | 12 #include "net/ssl/client_cert_store.h" |
13 #include "net/ssl/ssl_cert_request_info.h" | 13 #include "net/ssl/ssl_cert_request_info.h" |
14 | 14 |
| 15 typedef struct CERTCertListStr CERTCertList; |
| 16 |
15 namespace crypto { | 17 namespace crypto { |
16 class CryptoModuleBlockingPasswordDelegate; | 18 class CryptoModuleBlockingPasswordDelegate; |
17 } | 19 } |
18 | 20 |
19 namespace net { | 21 namespace net { |
20 | 22 |
21 class NET_EXPORT ClientCertStoreNSS : public ClientCertStore { | 23 class NET_EXPORT ClientCertStoreNSS : public ClientCertStore { |
22 public: | 24 public: |
23 typedef base::Callback<crypto::CryptoModuleBlockingPasswordDelegate*( | 25 typedef base::Callback<crypto::CryptoModuleBlockingPasswordDelegate*( |
24 const std::string& /* server */)> PasswordDelegateFactory; | 26 const std::string& /* server */)> PasswordDelegateFactory; |
25 | 27 |
26 explicit ClientCertStoreNSS( | 28 explicit ClientCertStoreNSS( |
27 const PasswordDelegateFactory& password_delegate_factory); | 29 const PasswordDelegateFactory& password_delegate_factory); |
28 virtual ~ClientCertStoreNSS(); | 30 virtual ~ClientCertStoreNSS(); |
29 | 31 |
30 // ClientCertStore: | 32 // ClientCertStore: |
31 virtual void GetClientCerts(const SSLCertRequestInfo& cert_request_info, | 33 virtual void GetClientCerts(const SSLCertRequestInfo& cert_request_info, |
32 CertificateList* selected_certs, | 34 CertificateList* selected_certs, |
33 const base::Closure& callback) OVERRIDE; | 35 const base::Closure& callback) OVERRIDE; |
34 | 36 |
| 37 protected: |
| 38 // Examines the certificates in |cert_list| to find all certificates that |
| 39 // match the client certificate request in |request|, storing the matching |
| 40 // certificates in |selected_certs|. |
| 41 // If |query_nssdb| is true, NSS will be queried to construct full certificate |
| 42 // chains. If it is false, only the certificate will be considered. |
| 43 virtual void GetClientCertsImpl(CERTCertList* cert_list, |
| 44 const SSLCertRequestInfo& request, |
| 45 bool query_nssdb, |
| 46 CertificateList* selected_certs); |
| 47 |
35 private: | 48 private: |
36 friend class ClientCertStoreNSSTestDelegate; | 49 friend class ClientCertStoreNSSTestDelegate; |
37 | 50 |
| 51 void GetClientCertsOnWorkerThread( |
| 52 scoped_ptr<crypto::CryptoModuleBlockingPasswordDelegate> |
| 53 password_delegate, |
| 54 const SSLCertRequestInfo* request, |
| 55 CertificateList* selected_certs); |
| 56 |
38 // A hook for testing. Filters |input_certs| using the logic being used to | 57 // A hook for testing. Filters |input_certs| using the logic being used to |
39 // filter the system store when GetClientCerts() is called. | 58 // filter the system store when GetClientCerts() is called. |
40 // Implemented by creating a list of certificates that otherwise would be | 59 // Implemented by creating a list of certificates that otherwise would be |
41 // extracted from the system store and filtering it using the common logic | 60 // extracted from the system store and filtering it using the common logic |
42 // (less adequate than the approach used on Windows). | 61 // (less adequate than the approach used on Windows). |
43 bool SelectClientCertsForTesting(const CertificateList& input_certs, | 62 bool SelectClientCertsForTesting(const CertificateList& input_certs, |
44 const SSLCertRequestInfo& cert_request_info, | 63 const SSLCertRequestInfo& cert_request_info, |
45 CertificateList* selected_certs); | 64 CertificateList* selected_certs); |
46 | 65 |
47 // The factory for creating the delegate for requesting a password to a | 66 // The factory for creating the delegate for requesting a password to a |
48 // PKCS #11 token. May be null. | 67 // PKCS #11 token. May be null. |
49 PasswordDelegateFactory password_delegate_factory_; | 68 PasswordDelegateFactory password_delegate_factory_; |
50 | 69 |
51 DISALLOW_COPY_AND_ASSIGN(ClientCertStoreNSS); | 70 DISALLOW_COPY_AND_ASSIGN(ClientCertStoreNSS); |
52 }; | 71 }; |
53 | 72 |
54 } // namespace net | 73 } // namespace net |
55 | 74 |
56 #endif // NET_SSL_CLIENT_CERT_STORE_NSS_H_ | 75 #endif // NET_SSL_CLIENT_CERT_STORE_NSS_H_ |
OLD | NEW |