Skip to content

Commit 11165d5

Browse files
committed
use TestRootCerts for additional_trust_anchors on OSX
Fix nwjs#6135
1 parent 70e7ae8 commit 11165d5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/browser/nw_chrome_browser_hooks.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "extensions/common/extension.h"
4949

5050
#include "net/cert/x509_certificate.h"
51+
#include "net/cert/test_root_certs.h"
5152
#include "net/url_request/url_request_context.h"
5253
#include "sql/connection.h"
5354
#include "sql/meta_table.h"
@@ -75,6 +76,7 @@ gfx::Image g_app_icon;
7576
int g_cdt_process_id = -1;
7677
std::string g_extension_id;
7778
bool g_reloading_app = false;
79+
net::CertificateList trust_anchors;
7880

7981
#if defined(OS_WIN)
8082
base::win::ScopedHICON g_window_hicon;
@@ -338,7 +340,6 @@ void MainPartsPreMainMessageLoopRunHook() {
338340
nw::Package* package = nw::package();
339341
const base::ListValue *additional_trust_anchors = NULL;
340342
if (package->root()->GetList("additional_trust_anchors", &additional_trust_anchors)) {
341-
net::CertificateList trust_anchors;
342343
for (size_t i = 0; i<additional_trust_anchors->GetSize(); i++) {
343344
std::string certificate_string;
344345
if (!additional_trust_anchors->GetString(i, &certificate_string)) {
@@ -360,7 +361,13 @@ void MainPartsPreMainMessageLoopRunHook() {
360361
trust_anchors.insert(trust_anchors.end(), loaded.begin(), loaded.end());
361362
}
362363
if (!trust_anchors.empty()) {
364+
#if !defined(OS_MACOSX)
363365
SetTrustAnchors(trust_anchors);
366+
#else
367+
net::TestRootCerts* certs = net::TestRootCerts::GetInstance();
368+
for (size_t i = 0; i < trust_anchors.size(); i++)
369+
certs->Add(trust_anchors[i].get());
370+
#endif
364371
}
365372
}
366373
}

0 commit comments

Comments
 (0)