Class: Uninterruptible::TLSServerFactory::CertificateChain

Inherits:
Object
  • Object
show all
Defined in:
lib/uninterruptible/tls_server_factory.rb

Overview

Extracts pulling multiple certificates out of one file

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cert_file) ⇒ CertificateChain

Returns a new instance of CertificateChain.



11
12
13
# File 'lib/uninterruptible/tls_server_factory.rb', line 11

def initialize(cert_file)
  @cert_file = cert_file
end

Instance Attribute Details

#cert_fileObject (readonly)

Returns the value of attribute cert_file.



9
10
11
# File 'lib/uninterruptible/tls_server_factory.rb', line 9

def cert_file
  @cert_file
end

Instance Method Details

#to_aObject



15
16
17
18
# File 'lib/uninterruptible/tls_server_factory.rb', line 15

def to_a
  certs = cert_file.scan(/-----BEGIN CERTIFICATE-----.+?-----END CERTIFICATE-----/m)
  certs.map { |cert| OpenSSL::X509::Certificate.new(cert) }
end