2018-04-12 20:15:04 +00:00
|
|
|
module PkeyReader
|
|
|
|
def read_pkey(filecontent, passphrase)
|
2019-02-22 15:10:50 +00:00
|
|
|
raise_if_unset(passphrase)
|
2018-04-12 20:15:04 +00:00
|
|
|
|
|
|
|
OpenSSL::PKey.read(filecontent, passphrase)
|
|
|
|
rescue OpenSSL::PKey::PKeyError
|
|
|
|
raise Inspec::Exceptions::ResourceFailed, 'passphrase error'
|
|
|
|
end
|
|
|
|
|
2019-02-22 15:10:50 +00:00
|
|
|
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'
|
2018-04-12 20:15:04 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|