Blame SOURCES/nodejs-use-system-certs.patch

498a18
From e0aac817a87c927f70a6f8edb63a4103a4109dfc Mon Sep 17 00:00:00 2001
498a18
From: Stephen Gallagher <sgallagh@redhat.com>
498a18
Date: Tue, 1 Dec 2015 16:29:07 -0500
498a18
Subject: [PATCH 2/2] Do not bundle CA Certificates
498a18
MIME-Version: 1.0
498a18
Content-Type: text/plain; charset=UTF-8
498a18
Content-Transfer-Encoding: 8bit
498a18
498a18
CA Certificates are provided by Fedora.
498a18
498a18
Forwarded: need some feedback before submitting the matter upstream
498a18
Author: Jérémy Lal <kapouer@melix.org>
498a18
Last-Update: 2014-03-02
498a18
498a18
Modified 2014-05-02 by T.C. Hollingsworth <tchollingsworth@gmail.com> with the
498a18
correct path for Fedora
498a18
498a18
Modified 2015-12-01 by Stephen Gallagher <sgallagh@redhat.com> to update for
498a18
Node.js 4.2
498a18
498a18
Modified 2016-03-04 by Stephen Gallagher <sgallagh@redhat.com> to update for
498a18
Node.js 5.7.1
498a18
---
498a18
 src/node_crypto.cc | 28 ++++++++--------------------
498a18
 1 file changed, 8 insertions(+), 20 deletions(-)
498a18
498a18
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
498a18
index acd83e9f2f41ade75ee9a3c8061acfa8b3dbf0f4..70ffe035f8be24b2eb6daf71185649d8ae7d579f 100644
498a18
--- a/src/node_crypto.cc
498a18
+++ b/src/node_crypto.cc
498a18
@@ -119,11 +119,11 @@ static X509_NAME *cnnic_ev_name =
498a18
                   sizeof(CNNIC_EV_ROOT_CA_SUBJECT_DATA)-1);
498a18
 
8ab518
 static Mutex* mutexes;
498a18
 
498a18
 const char* const root_certs[] = {
498a18
-#include "node_root_certs.h"  // NOLINT(build/include_order)
498a18
+  NULL
498a18
 };
498a18
 
498a18
 X509_STORE* root_cert_store;
498a18
 
498a18
 // Just to generate static methods
498a18
@@ -748,33 +748,21 @@ void SecureContext::AddRootCerts(const FunctionCallbackInfo<Value>& args) {
498a18
   (void) &clear_error_on_return;  // Silence compiler warning.
498a18
 
498a18
   CHECK_EQ(sc->ca_store_, nullptr);
498a18
 
498a18
   if (!root_cert_store) {
498a18
-    root_cert_store = X509_STORE_new();
498a18
-
8ab518
-    for (size_t i = 0; i < arraysize(root_certs); i++) {
498a18
-      BIO* bp = NodeBIO::NewFixed(root_certs[i], strlen(root_certs[i]));
498a18
-      if (bp == nullptr) {
498a18
-        return;
498a18
-      }
498a18
-
498a18
-      X509 *x509 = PEM_read_bio_X509(bp, nullptr, CryptoPemCallback, nullptr);
498a18
-      if (x509 == nullptr) {
498a18
-        BIO_free_all(bp);
498a18
-        return;
498a18
-      }
498a18
-
498a18
-      X509_STORE_add_cert(root_cert_store, x509);
498a18
-
498a18
-      BIO_free_all(bp);
498a18
-      X509_free(x509);
498a18
+    if (SSL_CTX_load_verify_locations(sc->ctx_, "/etc/pki/tls/certs/ca-bundle.crt", NULL) == 1) {
498a18
+      root_cert_store = SSL_CTX_get_cert_store(sc->ctx_);
498a18
+    } else {
498a18
+      // empty store
498a18
+      root_cert_store = X509_STORE_new();
498a18
     }
498a18
+  } else {
498a18
+    SSL_CTX_set_cert_store(sc->ctx_, root_cert_store);
498a18
   }
498a18
 
498a18
   sc->ca_store_ = root_cert_store;
498a18
-  SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_);
498a18
 }
498a18
 
498a18
 
498a18
 void SecureContext::SetCiphers(const FunctionCallbackInfo<Value>& args) {
8ab518
   SecureContext* sc;
498a18
-- 
498a18
2.7.2
498a18