[email protected] | 5482ef9e | 2013-12-11 04:27:43 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef NET_SSL_CLIENT_CERT_STORE_NSS_H_ | ||||
6 | #define NET_SSL_CLIENT_CERT_STORE_NSS_H_ | ||||
7 | |||||
[email protected] | 5482ef9e | 2013-12-11 04:27:43 | [diff] [blame] | 8 | #include "base/callback.h" |
pneubeck | 385704ec | 2015-08-25 08:56:37 | [diff] [blame] | 9 | #include "base/macros.h" |
[email protected] | 5482ef9e | 2013-12-11 04:27:43 | [diff] [blame] | 10 | #include "net/base/net_export.h" |
11 | #include "net/ssl/client_cert_store.h" | ||||
[email protected] | 5482ef9e | 2013-12-11 04:27:43 | [diff] [blame] | 12 | |
[email protected] | e53c0232 | 2013-12-17 00:09:00 | [diff] [blame] | 13 | typedef struct CERTCertListStr CERTCertList; |
Matt Mueller | 18f895e | 2017-09-01 04:58:49 | [diff] [blame] | 14 | typedef struct CERTCertificateStr CERTCertificate; |
[email protected] | e53c0232 | 2013-12-17 00:09:00 | [diff] [blame] | 15 | |
[email protected] | 5482ef9e | 2013-12-11 04:27:43 | [diff] [blame] | 16 | namespace crypto { |
17 | class CryptoModuleBlockingPasswordDelegate; | ||||
18 | } | ||||
19 | |||||
20 | namespace net { | ||||
pneubeck | 385704ec | 2015-08-25 08:56:37 | [diff] [blame] | 21 | class HostPortPair; |
22 | class SSLCertRequestInfo; | ||||
[email protected] | 5482ef9e | 2013-12-11 04:27:43 | [diff] [blame] | 23 | |
24 | class NET_EXPORT ClientCertStoreNSS : public ClientCertStore { | ||||
25 | public: | ||||
26 | typedef base::Callback<crypto::CryptoModuleBlockingPasswordDelegate*( | ||||
[email protected] | 791879c | 2013-12-17 07:22:41 | [diff] [blame] | 27 | const HostPortPair& /* server */)> PasswordDelegateFactory; |
[email protected] | 5482ef9e | 2013-12-11 04:27:43 | [diff] [blame] | 28 | |
Matt Mueller | 18f895e | 2017-09-01 04:58:49 | [diff] [blame] | 29 | using CertFilter = base::RepeatingCallback<bool(CERTCertificate*)>; |
30 | |||||
[email protected] | 5482ef9e | 2013-12-11 04:27:43 | [diff] [blame] | 31 | explicit ClientCertStoreNSS( |
32 | const PasswordDelegateFactory& password_delegate_factory); | ||||
dcheng | 67be2b1f | 2014-10-27 21:47:29 | [diff] [blame] | 33 | ~ClientCertStoreNSS() override; |
[email protected] | 5482ef9e | 2013-12-11 04:27:43 | [diff] [blame] | 34 | |
35 | // ClientCertStore: | ||||
dcheng | 67be2b1f | 2014-10-27 21:47:29 | [diff] [blame] | 36 | void GetClientCerts(const SSLCertRequestInfo& cert_request_info, |
mattm | 7ed243f | 2017-04-28 05:28:58 | [diff] [blame] | 37 | const ClientCertListCallback& callback) override; |
[email protected] | 5482ef9e | 2013-12-11 04:27:43 | [diff] [blame] | 38 | |
mattm | 436ccfe | 2017-06-19 20:24:08 | [diff] [blame] | 39 | // Examines the certificates in |identities| to find all certificates that |
40 | // match the client certificate request in |request|, removing any that don't. | ||||
41 | // The remaining certs will be updated to include intermediates. | ||||
pneubeck | 385704ec | 2015-08-25 08:56:37 | [diff] [blame] | 42 | // Must be called from a worker thread. |
mattm | 436ccfe | 2017-06-19 20:24:08 | [diff] [blame] | 43 | static void FilterCertsOnWorkerThread(ClientCertIdentityList* identities, |
44 | const SSLCertRequestInfo& request); | ||||
pneubeck | 385704ec | 2015-08-25 08:56:37 | [diff] [blame] | 45 | |
46 | // Retrieves all client certificates that are stored by NSS and adds them to | ||||
Matt Mueller | 18f895e | 2017-09-01 04:58:49 | [diff] [blame] | 47 | // |identities|. |password_delegate| is used to unlock slots if required. If |
48 | // |cert_filter| is not null, only certificates that it returns true on will | ||||
49 | // be added. | ||||
pneubeck | 385704ec | 2015-08-25 08:56:37 | [diff] [blame] | 50 | // Must be called from a worker thread. |
51 | static void GetPlatformCertsOnWorkerThread( | ||||
mattm | 436ccfe | 2017-06-19 20:24:08 | [diff] [blame] | 52 | scoped_refptr<crypto::CryptoModuleBlockingPasswordDelegate> |
pneubeck | 385704ec | 2015-08-25 08:56:37 | [diff] [blame] | 53 | password_delegate, |
Matt Mueller | 18f895e | 2017-09-01 04:58:49 | [diff] [blame] | 54 | const CertFilter& cert_filter, |
mattm | 436ccfe | 2017-06-19 20:24:08 | [diff] [blame] | 55 | ClientCertIdentityList* identities); |
[email protected] | e53c0232 | 2013-12-17 00:09:00 | [diff] [blame] | 56 | |
[email protected] | 5482ef9e | 2013-12-11 04:27:43 | [diff] [blame] | 57 | private: |
mattm | 436ccfe | 2017-06-19 20:24:08 | [diff] [blame] | 58 | ClientCertIdentityList GetAndFilterCertsOnWorkerThread( |
59 | scoped_refptr<crypto::CryptoModuleBlockingPasswordDelegate> | ||||
[email protected] | e53c0232 | 2013-12-17 00:09:00 | [diff] [blame] | 60 | password_delegate, |
mattm | 7ed243f | 2017-04-28 05:28:58 | [diff] [blame] | 61 | const SSLCertRequestInfo* request); |
[email protected] | e53c0232 | 2013-12-17 00:09:00 | [diff] [blame] | 62 | |
[email protected] | 5482ef9e | 2013-12-11 04:27:43 | [diff] [blame] | 63 | // The factory for creating the delegate for requesting a password to a |
pneubeck | 385704ec | 2015-08-25 08:56:37 | [diff] [blame] | 64 | // PKCS#11 token. May be null. |
[email protected] | 5482ef9e | 2013-12-11 04:27:43 | [diff] [blame] | 65 | PasswordDelegateFactory password_delegate_factory_; |
66 | |||||
67 | DISALLOW_COPY_AND_ASSIGN(ClientCertStoreNSS); | ||||
68 | }; | ||||
69 | |||||
70 | } // namespace net | ||||
71 | |||||
72 | #endif // NET_SSL_CLIENT_CERT_STORE_NSS_H_ |