From 161ea23655c35767a9254fd1617a0c567bc58b10 Mon Sep 17 00:00:00 2001
From: "Nicolas \"Pixel\" Noble" <pixel@nobis-crew.org>
Date: Sun, 22 Feb 2015 05:48:53 +0100
Subject: [PATCH] Actually installing root certificates on the system.

---
 Makefile                             | 7 ++++++-
 src/core/security/security_context.c | 4 ++--
 templates/Makefile.template          | 7 ++++++-
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index b39beeb549..b018febea1 100644
--- a/Makefile
+++ b/Makefile
@@ -1930,7 +1930,7 @@ $(OBJDIR)/$(CONFIG)/%.o : %.cc
 	$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
 
 
-install: install_c install_cxx install-plugins verify-install
+install: install_c install_cxx install-plugins install-certs verify-install
 
 install_c: install-headers_c install-static_c install-shared_c
 
@@ -2074,6 +2074,11 @@ else
 	$(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/grpc_ruby_plugin $(prefix)/bin/grpc_ruby_plugin
 endif
 
+install-certs: etc/roots.pem
+	$(E) "[INSTALL] Installing root certificates"
+	$(Q) $(INSTALL) -d $(prefix)/share/grpc
+	$(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
+
 verify-install:
 ifeq ($(SYSTEM_OK),true)
 	@echo "Your system looks ready to go."
diff --git a/src/core/security/security_context.c b/src/core/security/security_context.c
index ab3e0762b8..fd8baff539 100644
--- a/src/core/security/security_context.c
+++ b/src/core/security/security_context.c
@@ -61,9 +61,9 @@
   "SHA256:AES256-SHA256"
 
 #ifndef INSTALL_PREFIX
-static const char *installed_roots_path = "/etc/grpc/roots.pem";
+static const char *installed_roots_path = "/usr/share/grpc/roots.pem";
 #else
-static const char *installed_roots_path = INSTALL_PREFIX "/etc/grpc/roots.pem";
+static const char *installed_roots_path = INSTALL_PREFIX "/share/grpc/roots.pem";
 #endif
 
 /* -- Common methods. -- */
diff --git a/templates/Makefile.template b/templates/Makefile.template
index a93e23638d..22b382cdab 100644
--- a/templates/Makefile.template
+++ b/templates/Makefile.template
@@ -729,7 +729,7 @@ $(OBJDIR)/$(CONFIG)/%.o : %.cc
 	$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
 
 
-install: install_c install_cxx install-plugins verify-install
+install: install_c install_cxx install-plugins install-certs verify-install
 
 install_c: install-headers_c install-static_c install-shared_c
 
@@ -824,6 +824,11 @@ else
 % endfor
 endif
 
+install-certs: etc/roots.pem
+	$(E) "[INSTALL] Installing root certificates"
+	$(Q) $(INSTALL) -d $(prefix)/share/grpc
+	$(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
+
 verify-install:
 ifeq ($(SYSTEM_OK),true)
 	@echo "Your system looks ready to go."
-- 
GitLab