mirror of
https://github.com/inspec/inspec
synced 2024-11-22 20:53:11 +00:00
c9e8716310
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
15 lines
458 B
Ruby
15 lines
458 B
Ruby
module PkeyReader
|
|
def read_pkey(filecontent, passphrase)
|
|
raise_if_unset(passphrase)
|
|
|
|
OpenSSL::PKey.read(filecontent, passphrase)
|
|
rescue OpenSSL::PKey::PKeyError
|
|
raise Inspec::Exceptions::ResourceFailed, 'passphrase error'
|
|
end
|
|
|
|
def raise_if_unset(passphrase)
|
|
if passphrase.is_a? Inspec::Input::NO_VALUE_SET
|
|
raise Inspec::Exceptions::ResourceFailed, 'Please provide a value for input for openssl key passphrase'
|
|
end
|
|
end
|
|
end
|