Class: SSLyze::X509::Name
- Inherits:
-
Object
- Object
- SSLyze::X509::Name
- Includes:
- Enumerable
- Defined in:
- lib/sslyze/x509/name.rb
Overview
Wrapper object for OpenSSL::X509::Name.
Instance Attribute Summary collapse
-
#entries ⇒ Array<(String, String, Integer)>
readonly
The parsed entries of the name.
- #name ⇒ Object readonly protected
Instance Method Summary collapse
-
#[](key) ⇒ String?
Finds the entry with the matcing OID (Object IDentifier).
- #cmp(other) ⇒ Object
-
#common_name ⇒ Domain
(also: #cn)
The Common Name (
CN
) entry. -
#country_name ⇒ String
(also: #country, #c)
The Country (
C
) entry. -
#domain_component ⇒ String?
(also: #dc)
The Domain Component (
DC
) entry. -
#each {|oid, value, type| ... } ⇒ Object
Enumerates over the entries.
- #eql?(other) ⇒ Boolean
-
#initialize(name) ⇒ Name
constructor
A new instance of Name.
-
#location_name ⇒ String?
(also: #location, #l)
The Location (
L
) entry. -
#organization_name ⇒ String
(also: #organization, #o)
The Organization Name (
O
) entry. -
#organizational_unit_name ⇒ String
(also: #organizational_unit, #ou)
The Organization Unit Name (
OU
) entry. -
#state_name ⇒ String?
(also: #state, #province_name, #st)
The State/Province Name (
ST
) entry. - #to_a ⇒ Object
- #to_der ⇒ Object
- #to_s(*args) ⇒ Object
Constructor Details
#initialize(name) ⇒ Name
Returns a new instance of Name.
29 30 31 32 |
# File 'lib/sslyze/x509/name.rb', line 29 def initialize(name) @name = name @entries = name.to_a end |
Instance Attribute Details
#entries ⇒ Array<(String, String, Integer)> (readonly)
The parsed entries of the name.
23 24 25 |
# File 'lib/sslyze/x509/name.rb', line 23 def entries @entries end |
#name ⇒ Object (readonly, protected)
190 191 192 |
# File 'lib/sslyze/x509/name.rb', line 190 def name @name end |
Instance Method Details
#[](key) ⇒ String?
Finds the entry with the matcing OID (Object IDentifier).
61 62 63 64 65 66 67 |
# File 'lib/sslyze/x509/name.rb', line 61 def [](key) each do |oid,value,type| return value if oid == key end return nil end |
#cmp(other) ⇒ Object
156 157 158 |
# File 'lib/sslyze/x509/name.rb', line 156 def cmp(other) @name.cmp(other.name) end |
#common_name ⇒ Domain Also known as: cn
The Common Name (CN
) entry.
86 87 88 |
# File 'lib/sslyze/x509/name.rb', line 86 def common_name @common_name ||= Domain.new(self['CN']) end |
#country_name ⇒ String Also known as: country, c
The Country (C
) entry.
74 75 76 |
# File 'lib/sslyze/x509/name.rb', line 74 def country_name @country_name ||= self['C'] end |
#domain_component ⇒ String? Also known as: dc
The Domain Component (DC
) entry.
97 98 99 |
# File 'lib/sslyze/x509/name.rb', line 97 def domain_component @domain_component ||= self['DC'] end |
#each {|oid, value, type| ... } ⇒ Object
Enumerates over the entries.
48 49 50 51 52 |
# File 'lib/sslyze/x509/name.rb', line 48 def each(&block) @entries.each do |(oid,value,type)| yield oid, value, type end end |
#eql?(other) ⇒ Boolean
163 164 165 |
# File 'lib/sslyze/x509/name.rb', line 163 def eql?(other) @name.eql?(other.name) end |
#location_name ⇒ String? Also known as: location, l
The Location (L
) entry.
146 147 148 |
# File 'lib/sslyze/x509/name.rb', line 146 def location_name @location ||= self['L'] end |
#organization_name ⇒ String Also known as: organization, o
The Organization Name (O
) entry.
108 109 110 |
# File 'lib/sslyze/x509/name.rb', line 108 def organization_name @organization_name ||= self['O'] end |
#organizational_unit_name ⇒ String Also known as: organizational_unit, ou
The Organization Unit Name (OU
) entry.
120 121 122 |
# File 'lib/sslyze/x509/name.rb', line 120 def organizational_unit_name @organizational_unit_name ||= self['OU'] end |
#state_name ⇒ String? Also known as: state, province_name, st
The State/Province Name (ST
) entry.
132 133 134 |
# File 'lib/sslyze/x509/name.rb', line 132 def state_name @state_name ||= self['ST'] end |
#to_a ⇒ Object
170 171 172 |
# File 'lib/sslyze/x509/name.rb', line 170 def to_a @name.to_a end |
#to_der ⇒ Object
177 178 179 |
# File 'lib/sslyze/x509/name.rb', line 177 def to_der @name.to_der end |
#to_s(*args) ⇒ Object
184 185 186 |
# File 'lib/sslyze/x509/name.rb', line 184 def to_s(*args) @name.to_s(*args) end |