Class: CertCheck::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/cert_check/cli.rb

Overview

Cert-check’s command line interface

Instance Method Summary collapse

Instance Method Details

#info(*files) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cert_check/cli.rb', line 8

def info(*files)
  if files.empty?
    say_status :error,
               'Pass one or more certificate file paths as arguments.',
               :red
    exit(1)
  end

  files.each do |file|
    puts "CertFile:   #{file}"

    begin
      @cert = OpenSSL::X509::Certificate.new File.read file
    rescue OpenSSL::X509::CertificateError => e
      say_status :error,
                 "Certificate file is incorrect. (#{e.class}: #{e.message})\n\n",
                 :red
      next
    rescue StandardError => e
      say_status :error, "#{e.class}: #{e.message}\n\n", :red
      next
    end

    resources
    puts template
  end
end