2019-08-07 15:04:09 +00:00
|
|
|
// Copyright (c) 2019 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
2023-03-10 16:07:42 +00:00
|
|
|
#include "net/cert/cert_verify_result.h"
|
2019-08-07 15:04:09 +00:00
|
|
|
#include "shell/browser/net/cert_verifier_client.h"
|
|
|
|
|
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
VerifyRequestParams::VerifyRequestParams() = default;
|
|
|
|
|
|
|
|
VerifyRequestParams::~VerifyRequestParams() = default;
|
|
|
|
|
|
|
|
VerifyRequestParams::VerifyRequestParams(const VerifyRequestParams&) = default;
|
|
|
|
|
|
|
|
CertVerifierClient::CertVerifierClient(CertVerifyProc proc)
|
|
|
|
: cert_verify_proc_(proc) {}
|
|
|
|
|
|
|
|
CertVerifierClient::~CertVerifierClient() = default;
|
|
|
|
|
|
|
|
void CertVerifierClient::Verify(
|
|
|
|
int default_error,
|
|
|
|
const net::CertVerifyResult& default_result,
|
|
|
|
const scoped_refptr<net::X509Certificate>& certificate,
|
|
|
|
const std::string& hostname,
|
|
|
|
int flags,
|
2021-06-03 08:05:04 +00:00
|
|
|
const absl::optional<std::string>& ocsp_response,
|
2019-08-07 15:04:09 +00:00
|
|
|
VerifyCallback callback) {
|
|
|
|
VerifyRequestParams params;
|
|
|
|
params.hostname = hostname;
|
|
|
|
params.default_result = net::ErrorToString(default_error);
|
|
|
|
params.error_code = default_error;
|
|
|
|
params.certificate = certificate;
|
2020-01-27 18:48:29 +00:00
|
|
|
params.validated_certificate = default_result.verified_cert;
|
2021-08-02 01:24:58 +00:00
|
|
|
params.is_issued_by_known_root = default_result.is_issued_by_known_root;
|
2019-08-07 15:04:09 +00:00
|
|
|
cert_verify_proc_.Run(
|
|
|
|
params,
|
2021-06-16 22:43:51 +00:00
|
|
|
base::BindOnce(
|
2019-08-07 15:04:09 +00:00
|
|
|
[](VerifyCallback callback, const net::CertVerifyResult& result,
|
|
|
|
int err) { std::move(callback).Run(err, result); },
|
2021-06-16 22:43:51 +00:00
|
|
|
std::move(callback), default_result));
|
2019-08-07 15:04:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace electron
|