Sha256: fa2f0b82fec43aac4cc71b6b1e2c1778d613bc52c30a4b58c2db96f0bec2bdd5
Contents?: true
Size: 895 Bytes
Versions: 5
Compression:
Stored size: 895 Bytes
Contents
module SSLCheck module Validators class CommonName < GenericValidator def validate return nil if common_name_matches? SSLCheck::Errors::Validation::CommonNameMismatch.new({:name => "Common Name Mismatch", :message => "This certificate is not valid for #{@common_name}."}) end private def common_name_matches? matching_wildcard_domain || alternate_common_name_match || direct_common_name_match end def matching_wildcard_domain return true if (@peer_cert.common_name.match(/\*\./) && @common_name.include?(@peer_cert.common_name.gsub(/\*\./,''))) false end def direct_common_name_match @peer_cert.common_name.downcase == @common_name.downcase end def alternate_common_name_match @peer_cert.alternate_common_names.include?(@common_name.downcase) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems