mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
a278ae921b
Bug Fix #2865 * Defining an attribute without a default value generates a stacktrace * Fix string quotes * Moved logic out of the initilize method. * Refactoring for better clarity. * Fixing trailing white spaces Signed-off-by: Omar J Irizarry <irizarry_omar_j@network.lilly.com>
15 lines
454 B
Ruby
15 lines
454 B
Ruby
module PkeyReader
|
|
def read_pkey(filecontent, passphrase)
|
|
raise_if_default(passphrase)
|
|
|
|
OpenSSL::PKey.read(filecontent, passphrase)
|
|
rescue OpenSSL::PKey::PKeyError
|
|
raise Inspec::Exceptions::ResourceFailed, 'passphrase error'
|
|
end
|
|
|
|
def raise_if_default(passphrase)
|
|
if passphrase.is_a? Inspec::Attribute::DEFAULT_ATTRIBUTE
|
|
raise Inspec::Exceptions::ResourceFailed, 'Please provide default value for attribute'
|
|
end
|
|
end
|
|
end
|