Class: PoiseTlsRemoteFile::Resources::PoiseTlsRemoteFile::Resource

Inherits:
Chef::Resource::RemoteFile
  • Object
show all
Defined in:
lib/poise_tls_remote_file/resources/poise_tls_remote_file.rb

Overview

A tls_remote_file resource to do something.

Examples:

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

Since:

  • 1.0.0

Provides:

  • tls_remote_file

Actions:

  • run

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Resource

Returns a new instance of Resource.

Since:

  • 1.0.0



38
39
40
41
# 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

Instance Method Details

#ca_objsObject

Since:

  • 1.0.0



64
65
66
67
68
# 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_objObject

Since:

  • 1.0.0



47
48
49
# 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_objObject

Since:

  • 1.0.0



51
52
53
54
55
56
57
58
59
60
61
62
# 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