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



41
42
43
# File 'lib/sslcheck/validator.rb', line 41

def errors
  @errors.compact
end

#valid?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/sslcheck/validator.rb', line 37

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
34
35
# 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
  @ca_bundle = ca_bundle


  run_validations(validators)
end

#warningsObject



45
46
47
# File 'lib/sslcheck/validator.rb', line 45

def warnings
  []
end