mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
16 lines
454 B
Ruby
16 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
|