class SSLyze::X509::Extensions::SubjectAltName

Represents the `subjectAltName` X509v3 extension.

@since 1.0.0

Constants

TYPES

Known subject name types.

Public Instance Methods

dir_name() click to toggle source

All `dirName:` alternative names within the extension's value.

@return [Array<String>]

# File lib/sslyze/x509/extensions/subject_alt_name.rb, line 124
def dir_name
  @dir_name ||= select { |type,value| type == :dir_name }.map do |(type,value)|
    value
  end
end
dns() click to toggle source

All `DNS:` alternative names within the extension's value.

@return [Array<String>]

# File lib/sslyze/x509/extensions/subject_alt_name.rb, line 69
def dns
  @dns ||= select { |type,value| type == :dns }.map do |(type,value)|
    value
  end
end
each() { |TYPES, value| ... } click to toggle source

Enumerates over every alternative name within the extension's value.

@yield [type, name]

The given block will be passed each

@yieldparam [:dns, :ip, :uri, :rid, :email, :dir_name, :other_name] type

The type of the alternative name being yielded.

@yieldparam [String] name

An alternative name within the extension's value.

@return [Enumerator]

If no block is given, an Enumerator will be returned.

@raise [NotImplementedError]

An unknown name type was encountered while parsing the extension's
value.
# File lib/sslyze/x509/extensions/subject_alt_name.rb, line 50
def each
  return enum_for unless block_given?

  value.split(', ').each do |type_value|
    type, value = type_value.split(':',2)

    unless TYPES.has_key?(type)
      raise(NotImplementedError,"unsupported subjectAltName type: #{type}")
    end

    yield TYPES[type], value
  end
end
email() click to toggle source

All `email:` alternative names within the extension's value.

@return [Array<String>]

# File lib/sslyze/x509/extensions/subject_alt_name.rb, line 102
def email
  @email ||= select { |type,value| type == :email }.map do |(type,value)|
    value
  end
end
ip() click to toggle source

All `IP:` alternative names within the extension's value.

@return [Array<IPAddr>]

# File lib/sslyze/x509/extensions/subject_alt_name.rb, line 80
def ip
  @ip ||= select { |type,value| type == :ip }.map do |(type,value)|
    IPAddr.new(value)
  end
end
other_name() click to toggle source

All `otherName:` alternative names within the extension's value.

@return [Array<String>]

# File lib/sslyze/x509/extensions/subject_alt_name.rb, line 135
def other_name
  @other_name ||= select { |type,value| type == :other_name }.map do |(type,value)|
    value
  end
end
rid() click to toggle source

All `RID:` alternative names within the extension's value.

@return [Array<String>]

# File lib/sslyze/x509/extensions/subject_alt_name.rb, line 113
def rid
  @rid ||= select { |type,value| type == :rid }.map do |(type,value)|
    value
  end
end
uri() click to toggle source

All `URI:` alternative names within the extension's value.

@return [Array<URI::Generic>]

# File lib/sslyze/x509/extensions/subject_alt_name.rb, line 91
def uri
  @uri ||= select { |type,value| type == :uri }.map do |(type,value)|
    URI.parse(value)
  end
end