client_cert_store_mac.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #ifndef NET_SSL_CLIENT_CERT_STORE_MAC_H_
  5. #define NET_SSL_CLIENT_CERT_STORE_MAC_H_
  6. #include "base/callback.h"
  7. #include "net/base/net_export.h"
  8. #include "net/ssl/client_cert_store.h"
  9. #include "net/ssl/ssl_cert_request_info.h"
  10. namespace net {
  11. class ClientCertIdentityMac;
  12. class NET_EXPORT ClientCertStoreMac : public ClientCertStore {
  13. public:
  14. ClientCertStoreMac();
  15. ClientCertStoreMac(const ClientCertStoreMac&) = delete;
  16. ClientCertStoreMac& operator=(const ClientCertStoreMac&) = delete;
  17. ~ClientCertStoreMac() override;
  18. // ClientCertStore:
  19. void GetClientCerts(const SSLCertRequestInfo& cert_request_info,
  20. ClientCertListCallback callback) override;
  21. private:
  22. // TODO(https://crbug.com/1302761): Improve test coverage and remove/reduce
  23. // the friend tests and ForTesting methods.
  24. friend class ClientCertStoreMacTest;
  25. friend class ClientCertStoreMacTestDelegate;
  26. // A hook for testing. Filters |input_identities| using the logic being used
  27. // to filter the system store when GetClientCerts() is called. Implemented by
  28. // creating a list of certificates that otherwise would be extracted from the
  29. // system store and filtering it using the common logic (less adequate than
  30. // the approach used on Windows).
  31. bool SelectClientCertsForTesting(
  32. std::vector<std::unique_ptr<ClientCertIdentityMac>> input_identities,
  33. const SSLCertRequestInfo& cert_request_info,
  34. ClientCertIdentityList* selected_identities);
  35. // Testing hook specific to Mac, where the internal logic recognizes preferred
  36. // certificates for particular domains. If the preferred certificate is
  37. // present in the output list (i.e. it doesn't get filtered out), it should
  38. // always come first.
  39. bool SelectClientCertsGivenPreferredForTesting(
  40. std::unique_ptr<ClientCertIdentityMac> preferred_identity,
  41. std::vector<std::unique_ptr<ClientCertIdentityMac>> regular_identities,
  42. const SSLCertRequestInfo& request,
  43. ClientCertIdentityList* selected_identities);
  44. };
  45. } // namespace net
  46. #endif // NET_SSL_CLIENT_CERT_STORE_MAC_H_