diff options
author | Tim Smith <tsmith@chef.io> | 2018-08-14 09:33:33 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-08-14 11:23:59 -0700 |
commit | fe3d0deda9c32a35856ee977fdf5630f565e1d42 (patch) | |
tree | 48de8319e1636226003cc9727265890071a6292a | |
parent | d0f19a989b93754b3f781e00ee334866dde4e7b0 (diff) | |
download | chef-fe3d0deda9c32a35856ee977fdf5630f565e1d42.tar.gz |
Update priv_key_file_valid? helper to support EC keys
Ported from the openssl cookbook.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/mixin/openssl_helper.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/chef/mixin/openssl_helper.rb b/lib/chef/mixin/openssl_helper.rb index f12a559097..30830ace30 100644 --- a/lib/chef/mixin/openssl_helper.rb +++ b/lib/chef/mixin/openssl_helper.rb @@ -61,11 +61,16 @@ class Chef key_content = ::File.exist?(key_file) ? File.read(key_file) : key_file begin - key = ::OpenSSL::PKey::RSA.new key_content, key_password - rescue ::OpenSSL::PKey::RSAError + key = OpenSSL::PKey.read key_content, key_password + rescue OpenSSL::PKey::PKeyError, ArgumentError return false end - key.private? + + if key.is_a?(OpenSSL::PKey::EC) + key.private_key? + else + key.private? + end end # generate a dhparam file |