libraries/credentials_private_key.rb
#
# Private key of the credentials . This should be the actual key
# contents (as opposed to the path to a private key file) in OpenSSH
# format.
#
# @param [String] arg
# @return [String]
#
Private key of the credentials . This should be the actual key
contents (as opposed to the path to a private key file) in OpenSSH
format.
Private key of the credentials . This should be the actual key contents ( as opposed to the path to a private key file ) in OpenSSH format .
def to_pem(key=private_key)
      if key.is_a?(OpenSSL::PKey::RSA)
        Chef::Log.debug("private_key: is a OpenSSL::PKey::RSA (ruby openssl object)")
        key.to_pem
      elsif key.is_a?(OpenSSL::PKey::DSA)
        Chef::Log.debug("private_key: is a OpenSSL::PKey::DSA (ruby openssl object)")
        key.to_pem
      elsif key =~ /-----BEGIN RSA PRIVATE KEY-----/
        Chef::Log.debug("private_key: is text containing 'BEGIN RSA PRIVATE KEY' comment.")
        OpenSSL::PKey::RSA.new(key).to_pem
      elsif key =~ /-----BEGIN DSA PRIVATE KEY-----/
        Chef::Log.debug("private_key: is text containing 'BEGIN DSA PRIVATE KEY' comment.")
        OpenSSL::PKey::DSA.new(key).to_pem
      else
        Chef::Log.debug("private_key: falling back to instantiate a new OpenSSL::PKey::RSA (ruby openssl object)")
        OpenSSL::PKey::RSA.new(key).to_pem
      end
    end
def to_pem ( key = private_key ) if key . is_a? ( OpenSSL :: PKey :: RSA ) Chef :: Log . debug ( "private_key: is a OpenSSL::PKey::RSA (ruby openssl object)" ) key . to_pem elsif key . is_a? ( OpenSSL :: PKey :: DSA ) Chef :: Log . debug ( "private_key: is a OpenSSL::PKey::DSA (ruby openssl object)" ) key . to_pem elsif key =~ / -----BEGIN RSA PRIVATE KEY----- / Chef :: Log . debug ( "private_key: is text containing 'BEGIN RSA PRIVATE KEY' comment." ) OpenSSL :: PKey :: RSA . new ( key ) . to_pem elsif key =~ / -----BEGIN DSA PRIVATE KEY----- / Chef :: Log . debug ( "private_key: is text containing 'BEGIN DSA PRIVATE KEY' comment." ) OpenSSL :: PKey :: DSA . new ( key ) . to_pem else Chef :: Log . debug ( "private_key: falling back to instantiate a new OpenSSL::PKey::RSA (ruby openssl object)" ) OpenSSL :: PKey :: RSA . new ( key ) . to_pem end end
Private key of the credentials .
Private key of the credentials .
None
String
key
<not_specific>
private_key
<not_specific>
<not_specific>
None