Skip to content

Commit

Permalink
fix: don't crash on invalid certs (#21976)
Browse files Browse the repository at this point in the history
  • Loading branch information
nornagon committed Jan 31, 2020
1 parent c29ec2d commit 45f30ea
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions shell/browser/api/atom_api_app.cc
Expand Up @@ -9,6 +9,7 @@
#include <string>
#include <vector>

#include "base/callback_helpers.h"
#include "base/command_line.h"
#include "base/environment.h"
#include "base/files/file_path.h"
Expand Down Expand Up @@ -698,15 +699,17 @@ void App::AllowCertificateError(
bool is_main_frame_request,
bool strict_enforcement,
base::OnceCallback<void(content::CertificateRequestResultType)> callback) {
auto adapted_callback = base::AdaptCallbackForRepeating(std::move(callback));
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
bool prevent_default = Emit(
"certificate-error", WebContents::FromOrCreate(isolate(), web_contents),
request_url, net::ErrorToString(cert_error), ssl_info.cert, callback);
bool prevent_default =
Emit("certificate-error",
WebContents::FromOrCreate(isolate(), web_contents), request_url,
net::ErrorToString(cert_error), ssl_info.cert, adapted_callback);

// Deny the certificate by default.
if (!prevent_default)
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
adapted_callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
}

base::OnceClosure App::SelectClientCertificate(
Expand Down

0 comments on commit 45f30ea

Please sign in to comment.