Method: MDQT::CLI::Base#extract_certificate_paths

Defined in:
lib/mdqt/cli/base.rb

#extract_certificate_paths(cert_paths = options.verify_with) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
# File 'lib/mdqt/cli/base.rb', line 114

def extract_certificate_paths(cert_paths = options.verify_with)
  cert_paths.collect do |cert_path|
    begin
      halt! "Cannot read certificate at '#{cert_path}'!" unless File.readable?(cert_path)
      halt! "File at '#{cert_path}' does not seem to be a PEM format certificate" unless IO.binread(cert_path).include?("-----BEGIN CERTIFICATE-----")
      cert_path
    rescue
      halt! "Unable to validate the certificate at '#{cert_path}'"
    end
  end
end