nodejs18/nodejs-use-system-certs.patch

81 lines
2.2 KiB
Diff
Raw Normal View History

From e0aac817a87c927f70a6f8edb63a4103a4109dfc Mon Sep 17 00:00:00 2001
2015-12-02 00:48:58 +00:00
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Tue, 1 Dec 2015 16:29:07 -0500
Subject: [PATCH 2/2] Do not bundle CA Certificates
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
CA Certificates are provided by Fedora.
Forwarded: need some feedback before submitting the matter upstream
Author: Jérémy Lal <kapouer@melix.org>
Last-Update: 2014-03-02
Modified 2014-05-02 by T.C. Hollingsworth <tchollingsworth@gmail.com> with the
correct path for Fedora
2015-12-02 00:48:58 +00:00
Modified 2015-12-01 by Stephen Gallagher <sgallagh@redhat.com> to update for
Node.js 4.2
Modified 2016-03-04 by Stephen Gallagher <sgallagh@redhat.com> to update for
Node.js 5.7.1
2015-12-02 00:48:58 +00:00
Modified 2016-04-25 by Joseph Wang <joequant@gmail.com> to update for
Node.js 5.11.0
---
2015-12-02 00:48:58 +00:00
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 989110c..a55b69d 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -121,7 +121,7 @@ static X509_NAME *cnnic_ev_name =
2015-12-02 00:48:58 +00:00
static uv_mutex_t* locks;
2015-12-02 00:48:58 +00:00
const char* const root_certs[] = {
-#include "node_root_certs.h" // NOLINT(build/include_order)
2015-12-02 00:48:58 +00:00
+ NULL
};
2015-12-02 00:48:58 +00:00
X509_STORE* root_cert_store;
@@ -750,29 +750,17 @@ void SecureContext::AddRootCerts(const FunctionCallbackInfo<Value>& args) {
2015-12-02 00:48:58 +00:00
CHECK_EQ(sc->ca_store_, nullptr);
if (!root_cert_store) {
- root_cert_store = X509_STORE_new();
-
- for (size_t i = 0; i < arraysize(root_certs); i++) {
- BIO* bp = NodeBIO::NewFixed(root_certs[i], strlen(root_certs[i]));
- if (bp == nullptr) {
2015-12-02 00:48:58 +00:00
- return;
- }
-
2015-12-02 00:48:58 +00:00
- X509 *x509 = PEM_read_bio_X509(bp, nullptr, CryptoPemCallback, nullptr);
- if (x509 == nullptr) {
- BIO_free_all(bp);
- return;
- }
-
- X509_STORE_add_cert(root_cert_store, x509);
-
2015-12-02 00:48:58 +00:00
- BIO_free_all(bp);
- X509_free(x509);
+ if (SSL_CTX_load_verify_locations(sc->ctx_, "/etc/pki/tls/certs/ca-bundle.crt", NULL) == 1) {
+ root_cert_store = SSL_CTX_get_cert_store(sc->ctx_);
+ } else {
+ // empty store
+ root_cert_store = X509_STORE_new();
}
+ } else {
+ SSL_CTX_set_cert_store(sc->ctx_, root_cert_store);
}
2015-12-02 00:48:58 +00:00
sc->ca_store_ = root_cert_store;
- SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_);
}
2015-12-02 00:48:58 +00:00
2015-12-02 00:48:58 +00:00
--
2.7.2
2015-12-02 00:48:58 +00:00