ssl_config_service_mojo.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2018 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 SERVICES_NETWORK_SSL_CONFIG_SERVICE_MOJO_H_
  5. #define SERVICES_NETWORK_SSL_CONFIG_SERVICE_MOJO_H_
  6. #include "base/component_export.h"
  7. #include "base/memory/raw_ptr.h"
  8. #include "mojo/public/cpp/bindings/pending_receiver.h"
  9. #include "mojo/public/cpp/bindings/receiver.h"
  10. #include "net/cert/cert_verifier.h"
  11. #include "net/ssl/ssl_config_service.h"
  12. #include "services/network/crl_set_distributor.h"
  13. #include "services/network/public/mojom/ssl_config.mojom.h"
  14. namespace network {
  15. // An SSLConfigClient that serves as a net::SSLConfigService, listening to
  16. // SSLConfig changes on a Mojo pipe, and providing access to the updated config.
  17. class COMPONENT_EXPORT(NETWORK_SERVICE) SSLConfigServiceMojo
  18. : public mojom::SSLConfigClient,
  19. public net::SSLConfigService,
  20. public CRLSetDistributor::Observer {
  21. public:
  22. // If |ssl_config_client_receiver| is not provided, just sticks with the
  23. // initial configuration.
  24. // Note: |crl_set_distributor| must outlive this object.
  25. SSLConfigServiceMojo(
  26. mojom::SSLConfigPtr initial_config,
  27. mojo::PendingReceiver<mojom::SSLConfigClient> ssl_config_client_receiver,
  28. CRLSetDistributor* crl_set_distributor);
  29. SSLConfigServiceMojo(const SSLConfigServiceMojo&) = delete;
  30. SSLConfigServiceMojo& operator=(const SSLConfigServiceMojo&) = delete;
  31. ~SSLConfigServiceMojo() override;
  32. // Sets |cert_verifier| to be configured by certificate-related settings
  33. // provided by the mojom::SSLConfigClient via OnSSLConfigUpdated. Once set,
  34. // |cert_verifier| must outlive the SSLConfigServiceMojo or be cleared by
  35. // passing nullptr as |cert_verifier| prior to destruction.
  36. void SetCertVerifierForConfiguring(net::CertVerifier* cert_verifier);
  37. // mojom::SSLConfigClient implementation:
  38. void OnSSLConfigUpdated(const mojom::SSLConfigPtr ssl_config) override;
  39. // net::SSLConfigService implementation:
  40. net::SSLContextConfig GetSSLContextConfig() override;
  41. bool CanShareConnectionWithClientCerts(
  42. const std::string& hostname) const override;
  43. // CRLSetDistributor::Observer implementation:
  44. void OnNewCRLSet(scoped_refptr<net::CRLSet> crl_set) override;
  45. private:
  46. mojo::Receiver<mojom::SSLConfigClient> receiver_{this};
  47. net::SSLContextConfig ssl_context_config_;
  48. net::CertVerifier::Config cert_verifier_config_;
  49. raw_ptr<net::CertVerifier> cert_verifier_;
  50. raw_ptr<CRLSetDistributor> crl_set_distributor_;
  51. // The list of domains and subdomains from enterprise policy where connection
  52. // coalescing is allowed when client certs are in use if the hosts being
  53. // coalesced match this list.
  54. std::vector<std::string> client_cert_pooling_policy_;
  55. };
  56. } // namespace network
  57. #endif // SERVICES_NETWORK_SSL_CONFIG_SERVICE_MOJO_H_