From 23b92ef9ecc9bf89bd7776068d03fa0458c264c2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 5 Mar 2016 18:57:46 +0900 Subject: [PATCH] Fix passing certificate to select-client-certificate's callback --- atom/browser/api/atom_api_app.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index e54d7fee17..0c035af49b 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -132,19 +132,20 @@ void OnClientCertificateSelected( std::shared_ptr delegate, mate::Arguments* args) { mate::Dictionary cert_data; - if (!(args->Length() == 1 && args->GetNext(&cert_data))) { + if (!args->GetNext(&cert_data)) { args->ThrowError(); return; } - std::string encoded_data; - cert_data.Get("data", &encoded_data); + v8::Local data; + if (!cert_data.Get("data", &data)) + return; - auto certs = - net::X509Certificate::CreateCertificateListFromBytes( - encoded_data.data(), encoded_data.size(), - net::X509Certificate::FORMAT_AUTO); - delegate->ContinueWithCertificate(certs[0].get()); + auto certs = net::X509Certificate::CreateCertificateListFromBytes( + node::Buffer::Data(data), node::Buffer::Length(data), + net::X509Certificate::FORMAT_AUTO); + if (certs.size() > 0) + delegate->ContinueWithCertificate(certs[0].get()); } void PassLoginInformation(scoped_refptr login_handler,