diff options
author | Pete Higgins <pete@peterhiggins.org> | 2020-07-09 13:08:29 -0700 |
---|---|---|
committer | Pete Higgins <pete@peterhiggins.org> | 2020-07-09 13:34:51 -0700 |
commit | 6ce97b7e01381d42111960cd237b7ddae0e4b2fd (patch) | |
tree | 26f31b843c18184dbae79acf33846f3a4422ae55 | |
parent | d8a842e3541447b91f85c5258de2fcc88a896c09 (diff) | |
download | chef-6ce97b7e01381d42111960cd237b7ddae0e4b2fd.tar.gz |
Look for openssl.cnf if it is not in the default location.fix-windows-openssl-conf-test
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r-- | lib/chef/mixin/openssl_helper.rb | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/chef/mixin/openssl_helper.rb b/lib/chef/mixin/openssl_helper.rb index 1321bccfee..3cb20a4569 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)) @@ -390,7 +394,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", @@ -421,6 +427,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 |