class SSLCheck::Check

Attributes

ca_bundle[RW]
host_name[RW]
peer_cert[RW]

Public Class Methods

new(client=nil, validator=nil) click to toggle source
# File lib/sslcheck/check.rb, line 4
def initialize(client=nil, validator=nil)
  @client = client || Client.new
  @validator = validator || Validator.new
  @errors = []
  @checked = false
end

Public Instance Methods

check(url) click to toggle source
# File lib/sslcheck/check.rb, line 11
def check(url)
  fetch(url)
  validate if no_errors?
  @checked = true
  @url = url
  return self
end
checked?() click to toggle source
# File lib/sslcheck/check.rb, line 33
def checked?
  return true if @checked
  false
end
errors() click to toggle source
# File lib/sslcheck/check.rb, line 19
def errors
  @errors
end
failed?() click to toggle source
# File lib/sslcheck/check.rb, line 23
def failed?
  return false if no_errors?
  true
end
url() click to toggle source
# File lib/sslcheck/check.rb, line 38
def url
  @url
end
valid?() click to toggle source
# File lib/sslcheck/check.rb, line 28
def valid?
  return true if no_errors? && checked?
  false
end

Private Instance Methods

fetch(url) click to toggle source
# File lib/sslcheck/check.rb, line 48
def fetch(url)
  response = @client.get(url)

  if response.errors.empty?
    self.peer_cert = response.peer_cert
    self.ca_bundle = response.ca_bundle
    self.host_name = response.host_name
  end

  response.errors.each do |error|
    @errors << error
  end

  true
end
no_errors?() click to toggle source
# File lib/sslcheck/check.rb, line 44
def no_errors?
  @errors.empty?
end
validate() click to toggle source
# File lib/sslcheck/check.rb, line 64
def validate
  @validator.validate(host_name, peer_cert, ca_bundle)
  @errors = @errors + @validator.errors
  true
end