inspec/lib/utils/pkey_reader.rb
Clinton Wolfe c9e8716310 Change two more mentions of DEFAULT_ATTRIBUTE
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
2019-02-22 10:10:50 -05:00

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