summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-07-15 13:05:10 -0700
committerGitHub <noreply@github.com>2020-07-15 13:05:10 -0700
commit79b7b5a373311b891e94ab2c8d7900a2e3f80eb5 (patch)
tree87da692d4613a006a7dac48df25af66cc26e6012 /lib
parent0964c87d0cf694930b8f870c3063a88a8418ea01 (diff)
parentfbfced7c98f7b5c7f357dee87c4d55d3ef83f65a (diff)
downloadchef-79b7b5a373311b891e94ab2c8d7900a2e3f80eb5.tar.gz
Merge pull request #10168 from chef/testing
Backport various testing fixes from Infra Client 16
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/mixin/openssl_helper.rb29
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/chef/mixin/openssl_helper.rb b/lib/chef/mixin/openssl_helper.rb
index 7b94096a79..df6779c8a1 100644
--- a/lib/chef/mixin/openssl_helper.rb
+++ b/lib/chef/mixin/openssl_helper.rb
@@ -282,7 +282,9 @@ class Chef
ef.issuer_certificate = info["issuer"]
end
ef.subject_certificate = cert
- ef.config = ::OpenSSL::Config.load(::OpenSSL::Config::DEFAULT_CONFIG_FILE)
+ if openssl_config = __openssl_config
+ ef.config = openssl_config
+ end
cert.extensions = extension
cert.add_extension ef.create_extension("subjectKeyIdentifier", "hash")
@@ -313,7 +315,9 @@ class Chef
crl.last_update = Time.now
crl.next_update = Time.now + 3600 * 24 * info["validity"]
- ef.config = ::OpenSSL::Config.load(::OpenSSL::Config::DEFAULT_CONFIG_FILE)
+ if openssl_config = __openssl_config
+ ef.config = openssl_config
+ end
ef.issuer_certificate = info["issuer"]
crl.add_extension ::OpenSSL::X509::Extension.new("crlNumber", ::OpenSSL::ASN1::Integer(1))
@@ -391,7 +395,9 @@ class Chef
crl.next_update = crl.last_update + 3600 * 24 * info["validity"]
ef = ::OpenSSL::X509::ExtensionFactory.new
- ef.config = ::OpenSSL::Config.load(::OpenSSL::Config::DEFAULT_CONFIG_FILE)
+ if openssl_config = __openssl_config
+ ef.config = openssl_config
+ end
ef.issuer_certificate = info["issuer"]
crl.extensions = [ ::OpenSSL::X509::Extension.new("crlNumber",
@@ -422,6 +428,23 @@ class Chef
resp
end
+
+ private
+
+ def __openssl_config
+ path = if File.exist?(::OpenSSL::Config::DEFAULT_CONFIG_FILE)
+ OpenSSL::Config::DEFAULT_CONFIG_FILE
+ else
+ Dir[File.join(RbConfig::CONFIG["prefix"], "**", "openssl.cnf")].first
+ end
+
+ if File.exist?(path)
+ ::OpenSSL::Config.load(path)
+ else
+ Chef::Log.warn("Couldn't find OpenSSL config file")
+ nil
+ end
+ end
end
end
end