-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: mv CertVerifierClient to separate header
- Loading branch information
1 parent
703edd2
commit 89d6ec0
Showing
6 changed files
with
120 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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 "shell/browser/net/cert_verifier_client.h" | ||
#include "shell/common/native_mate_converters/net_converter.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, | ||
const base::Optional<std::string>& ocsp_response, | ||
VerifyCallback callback) { | ||
VerifyRequestParams params; | ||
params.hostname = hostname; | ||
params.default_result = net::ErrorToString(default_error); | ||
params.error_code = default_error; | ||
params.certificate = certificate; | ||
cert_verify_proc_.Run( | ||
params, | ||
base::AdaptCallbackForRepeating(base::BindOnce( | ||
[](VerifyCallback callback, const net::CertVerifyResult& result, | ||
int err) { std::move(callback).Run(err, result); }, | ||
std::move(callback), default_result))); | ||
} | ||
|
||
} // namespace electron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) 2019 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef SHELL_BROWSER_NET_CERT_VERIFIER_CLIENT_H_ | ||
#define SHELL_BROWSER_NET_CERT_VERIFIER_CLIENT_H_ | ||
|
||
#include <string> | ||
|
||
#include "net/cert/x509_certificate.h" | ||
#include "services/network/public/mojom/network_context.mojom.h" | ||
|
||
namespace electron { | ||
|
||
struct VerifyRequestParams { | ||
std::string hostname; | ||
std::string default_result; | ||
int error_code; | ||
scoped_refptr<net::X509Certificate> certificate; | ||
|
||
VerifyRequestParams(); | ||
VerifyRequestParams(const VerifyRequestParams&); | ||
~VerifyRequestParams(); | ||
}; | ||
|
||
class CertVerifierClient : public network::mojom::CertVerifierClient { | ||
public: | ||
using CertVerifyProc = | ||
base::RepeatingCallback<void(const VerifyRequestParams& request, | ||
base::RepeatingCallback<void(int)>)>; | ||
|
||
explicit CertVerifierClient(CertVerifyProc proc); | ||
~CertVerifierClient() override; | ||
|
||
// network::mojom::CertVerifierClient | ||
void Verify(int default_error, | ||
const net::CertVerifyResult& default_result, | ||
const scoped_refptr<net::X509Certificate>& certificate, | ||
const std::string& hostname, | ||
int flags, | ||
const base::Optional<std::string>& ocsp_response, | ||
VerifyCallback callback) override; | ||
|
||
private: | ||
CertVerifyProc cert_verify_proc_; | ||
}; | ||
|
||
} // namespace electron | ||
|
||
#endif // SHELL_BROWSER_NET_CERT_VERIFIER_CLIENT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters