def canonical_key
      return @canonical_key if @canonical_key

      log.info "Parsing private key..."

      if @key.nil?
        log.warn "No private key given!"
        raise 'No private key given!'
      end

      if @key.is_a?(OpenSSL::PKey::RSA)
        log.debug "Detected private key is an OpenSSL Ruby object"
        @canonical_key = @key
      elsif @key =~ /(.+)\.pem$/ || File.exists?(File.expand_path(@key))
        log.debug "Detected private key is the path to a file"
        contents = File.read(File.expand_path(@key))
        @canonical_key = OpenSSL::PKey::RSA.new(contents)
      else
        log.debug "Detected private key was the literal string key"
        @canonical_key = OpenSSL::PKey::RSA.new(@key)
      end

      @canonical_key
    end
def canonical_key
      return @canonical_key if @canonical_key

      log.info "Parsing private key..."

      if @key.nil?
        log.warn "No private key given!"
        raise 'No private key given!'
      end

      if @key.is_a?(OpenSSL::PKey::RSA)
        log.debug "Detected private key is an OpenSSL Ruby object"
        @canonical_key = @key
      elsif @key =~ /(.+)\.pem$/ || File.exists?(File.expand_path(@key))
        log.debug "Detected private key is the path to a file"
        contents = File.read(File.expand_path(@key))
        @canonical_key = OpenSSL::PKey::RSA.new(contents)
      else
        log.debug "Detected private key was the literal string key"
        @canonical_key = OpenSSL::PKey::RSA.new(@key)
      end

      @canonical_key
    end
Parse the given private key. Users can specify the private key as:

   - the path to the key on disk
   - the raw string key
   - an +OpenSSL::PKey::RSA object+

 Any other implementations are not supported and will likely explode.

 @todo
   Handle errors when the file cannot be read due to insufficient
   permissions

 @return [OpenSSL::PKey::RSA]
   the RSA private key as an OpenSSL object