class PoiseTlsRemoteFile::Resources::PoiseTlsRemoteFile::Resource

A `tls_remote_file` resource to do something.

@provides tls_remote_file @action run @example

tls_remote_file '/path/to/file' do
  client_cert '/etc/ssl/client.crt'
  client_key '/etc/ssl/private/client.key'
end

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/poise_tls_remote_file/resources/poise_tls_remote_file.rb, line 38
def initialize(*args)
  super
  @provider = PoiseTlsRemoteFile::Provider if defined?(@provider)
end

Public Instance Methods

ca_objs() click to toggle source
# File lib/poise_tls_remote_file/resources/poise_tls_remote_file.rb, line 64
def ca_objs
  Array(ca).map do |path|
    OpenSSL::X509::Certificate.new(maybe_read_file(path)) if path
  end
end
client_cert_obj() click to toggle source
# File lib/poise_tls_remote_file/resources/poise_tls_remote_file.rb, line 47
def client_cert_obj
  OpenSSL::X509::Certificate.new(maybe_read_file(client_cert)) if client_cert
end
client_key_obj() click to toggle source
# File lib/poise_tls_remote_file/resources/poise_tls_remote_file.rb, line 51
def client_key_obj
  if client_key
    OpenSSL::PKey::RSA.new(maybe_read_file(client_key))
  elsif client_cert
    begin
      OpenSSL::PKey::RSA.new(maybe_read_file(client_cert))
    rescue OpenSSL::PKey::RSAError
      # It didn't have a key in it, oh well.
      nil
    end
  end
end

Private Instance Methods

default_ca() click to toggle source
# File lib/poise_tls_remote_file/resources/poise_tls_remote_file.rb, line 80
def default_ca
  node['poise-tls-remote-file']['ca']
end
default_client_cert() click to toggle source
# File lib/poise_tls_remote_file/resources/poise_tls_remote_file.rb, line 72
def default_client_cert
  node['poise-tls-remote-file']['client_cert']
end
default_client_key() click to toggle source
# File lib/poise_tls_remote_file/resources/poise_tls_remote_file.rb, line 76
def default_client_key
  node['poise-tls-remote-file']['client_key']
end
maybe_read_file(path) click to toggle source
# File lib/poise_tls_remote_file/resources/poise_tls_remote_file.rb, line 84
def maybe_read_file(path)
  if path =~ /\A(\/|\w:)/
    IO.read(path)
  else
    # Looks like a literal value.
    path
  end
end