class SSLCheck::Validator
Public Class Methods
new()
click to toggle source
# 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
Public Instance Methods
errors()
click to toggle source
# File lib/sslcheck/validator.rb, line 41 def errors @errors.compact end
valid?()
click to toggle source
# File lib/sslcheck/validator.rb, line 37 def valid? @validated && errors.empty? end
validate(common_name=nil, peer_cert=nil, ca_bundle=[], validators=[])
click to toggle source
# 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
warnings()
click to toggle source
# File lib/sslcheck/validator.rb, line 45 def warnings [] end
Private Instance Methods
run_validations(validators)
click to toggle source
# File lib/sslcheck/validator.rb, line 50 def run_validations(validators) validators = @default_validators if validators.empty? validators.each do |validator| @errors << validator.new(@common_name, @peer_cert, @ca_bundle).validate end @validated = true end