Commit f4319899 authored by Julien Huon's avatar Julien Huon
Browse files

Fix Issue #72 (backward compatibility with chef 12)


Signed-off-by: default avatarJulien Huon <juju482@gmail.com>
parent 5eab839c
......@@ -27,7 +27,7 @@ This cookbook provides tools for working with the Ruby OpenSSL library. It inclu
## Chef
- Chef 13.0+
- Chef 12.7+
## Cookbooks
......
......@@ -44,10 +44,15 @@ module OpenSSLCookbook
begin
key = OpenSSL::PKey.read key_content, key_password
rescue OpenSSL::PKey::PKeyError
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
# given a crl file path see if it's actually a crl
......@@ -135,7 +140,7 @@ module OpenSSLCookbook
def gen_ec_priv_key(curve)
raise TypeError, 'curve must be a string' unless curve.is_a?(String)
raise ArgumentError, 'Specified curve is not available on this system' unless curve == 'prime256v1' || curve == 'secp384r1' || curve == 'secp521r1'
OpenSSL::PKey::EC.generate(curve)
OpenSSL::PKey::EC.new(curve).generate_key
end
# generate pem format of the public key given a private key
......@@ -190,6 +195,9 @@ module OpenSSLCookbook
request.subject = subject
request.public_key = key
# Chef 12 backward compatibility
OpenSSL::PKey::EC.send(:alias_method, :private?, :private_key?)
request.sign(key, OpenSSL::Digest::SHA256.new)
request
end
......
......@@ -303,5 +303,5 @@ openssl_x509_request '/etc/ssl_test/my_rsa_request2.csr' do
org 'Test Kitchen Example'
org_unit 'Kitchens'
country 'UK'
key_file '/etc/ssl_test/my_ec_request.key'
key_file '/etc/ssl_test/my_rsa_request.key'
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment