cert_verifier_client.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (c) 2019 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_BROWSER_NET_CERT_VERIFIER_CLIENT_H_
  5. #define ELECTRON_SHELL_BROWSER_NET_CERT_VERIFIER_CLIENT_H_
  6. #include <string>
  7. #include "net/cert/x509_certificate.h"
  8. #include "services/network/public/mojom/network_context.mojom.h"
  9. namespace electron {
  10. struct VerifyRequestParams {
  11. std::string hostname;
  12. std::string default_result;
  13. int error_code;
  14. scoped_refptr<net::X509Certificate> certificate;
  15. scoped_refptr<net::X509Certificate> validated_certificate;
  16. bool is_issued_by_known_root;
  17. VerifyRequestParams();
  18. VerifyRequestParams(const VerifyRequestParams&);
  19. ~VerifyRequestParams();
  20. };
  21. class CertVerifierClient : public network::mojom::CertVerifierClient {
  22. public:
  23. using CertVerifyProc =
  24. base::RepeatingCallback<void(const VerifyRequestParams& request,
  25. base::OnceCallback<void(int)>)>;
  26. explicit CertVerifierClient(CertVerifyProc proc);
  27. ~CertVerifierClient() override;
  28. // network::mojom::CertVerifierClient
  29. void Verify(int default_error,
  30. const net::CertVerifyResult& default_result,
  31. const scoped_refptr<net::X509Certificate>& certificate,
  32. const std::string& hostname,
  33. int flags,
  34. const absl::optional<std::string>& ocsp_response,
  35. VerifyCallback callback) override;
  36. private:
  37. CertVerifyProc cert_verify_proc_;
  38. };
  39. } // namespace electron
  40. #endif // ELECTRON_SHELL_BROWSER_NET_CERT_VERIFIER_CLIENT_H_