Method: Inspec::Resources::X509CertificateResource#initialize

Defined in:
lib/resources/x509_certificate.rb

#initialize(filename) ⇒ X509CertificateResource

Returns a new instance of X509CertificateResource.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/resources/x509_certificate.rb', line 36

def initialize(filename)
  @certpath = filename
  @issuer = nil
  @parsed_subject = nil
  @parsed_issuer = nil
  @extensions = nil

  file = inspec.file(@certpath)
  return skip_resource "Unable to find certificate file #{@certpath}" unless file.exist?

  begin
    @cert = OpenSSL::X509::Certificate.new file.content
  rescue OpenSSL::X509::CertificateError
    @cert = nil
    return skip_resource "Unable to load certificate #{@certpath}"
  end
end