class SSLyze::X509::Domain

Represents a domain name pattern.

@since 1.0.0

Attributes

domain[R]

The domain part of the subject name.

@return [String]

name[R]

The subject name.

@return [String]

suffix[R]

The literal suffix of the subject name.

@return [String]

to_s[R]

The subject name.

@return [String]

to_str[R]

The subject name.

@return [String]

Public Class Methods

new(name) click to toggle source

Initializes the subject name.

@param [String] name

The subject name.
# File lib/sslyze/x509/domain.rb, line 31
def initialize(name)
  @name = name

  if @name.start_with?('*.')
    @suffix = @name[1..-1]
    @domain = @name[2..-1]
  else
    @domain = @name
  end
end

Public Instance Methods

==(other) click to toggle source

Compares two subject names.

@return [Boolean]

# File lib/sslyze/x509/domain.rb, line 47
def ==(other)
  other.kind_of?(self.class) && @name == other.name
end
===(domain)
Alias for: include?
include?(domain) click to toggle source

Tests whether the domain is matched by the subject name.

# File lib/sslyze/x509/domain.rb, line 54
def include?(domain)
  if @name.start_with?('*.') # wildcard
    domain.end_with?(@suffix) || # does the domain share the suffix
      domain == @domain            # does the domain match the suffix
  else # exact match
    domain == @name
  end
end
Also aliased as: ===
inspect() click to toggle source

Inspects the subject name.

@return [String]

# File lib/sslyze/x509/domain.rb, line 73
def inspect
  "#<#{self.class}: #{self}>"
end