diff options
author | Tim Smith <tsmith@chef.io> | 2020-07-09 15:02:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-09 15:02:02 -0700 |
commit | 54f6c5e775e5e63890c846b036f9f5d15655da1f (patch) | |
tree | 47e786f7eee7b9fd1a7290d9ffb0bcef2a487565 | |
parent | 4d952c659eaa4b7e69cfa3a9b07db5199a83bd42 (diff) | |
parent | 6ce97b7e01381d42111960cd237b7ddae0e4b2fd (diff) | |
download | chef-54f6c5e775e5e63890c846b036f9f5d15655da1f.tar.gz |
Merge pull request #10138 from chef/fix-windows-openssl-conf-test
Fix openssl config tests on Windows
-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 |