From 0d6085e2e5304b052f5a6a0a3facd0e9671691a5 Mon Sep 17 00:00:00 2001 From: Michal Cichra Date: Tue, 27 Jun 2017 08:52:54 +0200 Subject: [PATCH] [ssl] respect SSL_CERT_DIR and SSL_CERT_FILE respect SSL_CERT_DIR and SSL_CERT_FILE environment variables --- lib/httpclient/ssl_config.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/httpclient/ssl_config.rb b/lib/httpclient/ssl_config.rb index f6e7ce92..c11dea2b 100644 --- a/lib/httpclient/ssl_config.rb +++ b/lib/httpclient/ssl_config.rb @@ -415,8 +415,15 @@ def change_notify # Use 2048 bit certs trust anchor def load_cacerts(cert_store) - file = File.join(File.dirname(__FILE__), 'cacert.pem') - add_trust_ca_to_store(cert_store, file) + certs = if ENV.key?('SSL_CERT_DIR'.freeze) || ENV.key?('SSL_CERT_FILE') + [ ENV['SSL_CERT_DIR'.freeze], ENV['SSL_CERT_FILE'] ].compact + else + [ File.join(File.dirname(__FILE__), 'cacert.pem') ] + end + + certs.each do |cert| + add_trust_ca_to_store(cert_store, cert) + end end end