class SSLCheck::Validators::CommonName
Public Instance Methods
validate()
click to toggle source
# File lib/sslcheck/validators/common_name.rb, line 4 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 Instance Methods
alternate_common_name_match()
click to toggle source
# File lib/sslcheck/validators/common_name.rb, line 23 def alternate_common_name_match @peer_cert.alternate_common_names.include?(@common_name.downcase) end
common_name_matches?()
click to toggle source
# File lib/sslcheck/validators/common_name.rb, line 10 def common_name_matches? matching_wildcard_domain || alternate_common_name_match || direct_common_name_match end
direct_common_name_match()
click to toggle source
# File lib/sslcheck/validators/common_name.rb, line 19 def direct_common_name_match @peer_cert.common_name.downcase == @common_name.downcase end
matching_wildcard_domain()
click to toggle source
# File lib/sslcheck/validators/common_name.rb, line 14 def matching_wildcard_domain return true if (@peer_cert.common_name.match(/\*\./) && @common_name.include?(@peer_cert.common_name.gsub(/\*\./,''))) false end