blob: 465569ecdce52a160b42c7041e5efedfae8f642d [file] [log] [blame]
[email protected]5482ef9e2013-12-11 04:27:431// 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]5482ef9e2013-12-11 04:27:438#include "base/callback.h"
pneubeck385704ec2015-08-25 08:56:379#include "base/macros.h"
[email protected]5482ef9e2013-12-11 04:27:4310#include "net/base/net_export.h"
11#include "net/ssl/client_cert_store.h"
[email protected]5482ef9e2013-12-11 04:27:4312
[email protected]e53c02322013-12-17 00:09:0013typedef struct CERTCertListStr CERTCertList;
Matt Mueller18f895e2017-09-01 04:58:4914typedef struct CERTCertificateStr CERTCertificate;
[email protected]e53c02322013-12-17 00:09:0015
[email protected]5482ef9e2013-12-11 04:27:4316namespace crypto {
17class CryptoModuleBlockingPasswordDelegate;
18}
19
20namespace net {
pneubeck385704ec2015-08-25 08:56:3721class HostPortPair;
22class SSLCertRequestInfo;
[email protected]5482ef9e2013-12-11 04:27:4323
24class NET_EXPORT ClientCertStoreNSS : public ClientCertStore {
25 public:
26 typedef base::Callback<crypto::CryptoModuleBlockingPasswordDelegate*(
[email protected]791879c2013-12-17 07:22:4127 const HostPortPair& /* server */)> PasswordDelegateFactory;
[email protected]5482ef9e2013-12-11 04:27:4328
Matt Mueller18f895e2017-09-01 04:58:4929 using CertFilter = base::RepeatingCallback<bool(CERTCertificate*)>;
30
[email protected]5482ef9e2013-12-11 04:27:4331 explicit ClientCertStoreNSS(
32 const PasswordDelegateFactory& password_delegate_factory);
dcheng67be2b1f2014-10-27 21:47:2933 ~ClientCertStoreNSS() override;
[email protected]5482ef9e2013-12-11 04:27:4334
35 // ClientCertStore:
dcheng67be2b1f2014-10-27 21:47:2936 void GetClientCerts(const SSLCertRequestInfo& cert_request_info,
mattm7ed243f2017-04-28 05:28:5837 const ClientCertListCallback& callback) override;
[email protected]5482ef9e2013-12-11 04:27:4338
mattm436ccfe2017-06-19 20:24:0839 // 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.
pneubeck385704ec2015-08-25 08:56:3742 // Must be called from a worker thread.
mattm436ccfe2017-06-19 20:24:0843 static void FilterCertsOnWorkerThread(ClientCertIdentityList* identities,
44 const SSLCertRequestInfo& request);
pneubeck385704ec2015-08-25 08:56:3745
46 // Retrieves all client certificates that are stored by NSS and adds them to
Matt Mueller18f895e2017-09-01 04:58:4947 // |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.
pneubeck385704ec2015-08-25 08:56:3750 // Must be called from a worker thread.
51 static void GetPlatformCertsOnWorkerThread(
mattm436ccfe2017-06-19 20:24:0852 scoped_refptr<crypto::CryptoModuleBlockingPasswordDelegate>
pneubeck385704ec2015-08-25 08:56:3753 password_delegate,
Matt Mueller18f895e2017-09-01 04:58:4954 const CertFilter& cert_filter,
mattm436ccfe2017-06-19 20:24:0855 ClientCertIdentityList* identities);
[email protected]e53c02322013-12-17 00:09:0056
[email protected]5482ef9e2013-12-11 04:27:4357 private:
mattm436ccfe2017-06-19 20:24:0858 ClientCertIdentityList GetAndFilterCertsOnWorkerThread(
59 scoped_refptr<crypto::CryptoModuleBlockingPasswordDelegate>
[email protected]e53c02322013-12-17 00:09:0060 password_delegate,
mattm7ed243f2017-04-28 05:28:5861 const SSLCertRequestInfo* request);
[email protected]e53c02322013-12-17 00:09:0062
[email protected]5482ef9e2013-12-11 04:27:4363 // The factory for creating the delegate for requesting a password to a
pneubeck385704ec2015-08-25 08:56:3764 // PKCS#11 token. May be null.
[email protected]5482ef9e2013-12-11 04:27:4365 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_