Class: SSLCheck::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/sslcheck/validator.rb

Defined Under Namespace

Classes: CABundleMissingError, CommonNameMissingError, PeerCertificateMissingError

Instance Method Summary collapse

Constructor Details

#initializeValidator

Returns a new instance of Validator.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sslcheck/validator.rb', line 9

def initialize
  @valid       = false
  @errors      = []
  @warnings    = []
  @common_name = nil
  @peer_cert   = nil
  @ca_bundle   = []
  @validated   = false
  @default_validators = [
    Validators::CommonName,
    Validators::IssueDate,
    Validators::ExpirationDate,
    Validators::CABundle,
  ]
end

Instance Method Details

#errorsObject



39
40
41
# File 'lib/sslcheck/validator.rb', line 39

def errors
  @errors.compact
end

#valid?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/sslcheck/validator.rb', line 35

def valid?
  @validated && errors.empty?
end

#validate(common_name = nil, peer_cert = nil, ca_bundle = [], validators = []) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/sslcheck/validator.rb', line 25

def validate(common_name=nil, peer_cert=nil, ca_bundle=[], validators=[])
  raise CommonNameMissingError if common_name.nil? || common_name.empty?
  raise PeerCertificateMissingError if peer_cert.nil?
  raise CABundleMissingError if ca_bundle.nil? || ca_bundle.empty?
  @common_name = common_name
  @peer_cert = peer_cert

  run_validations(validators)
end

#warningsObject



43
44
45
# File 'lib/sslcheck/validator.rb', line 43

def warnings
  []
end