Class: EzCrypto::Name
- Inherits:
-
Object
- Object
- EzCrypto::Name
- Defined in:
- lib/ezsig.rb
Overview
A handy ruby wrapper around OpenSSL’s Name object. This was created to make it really easy to extract information out of the certificate.
Instance Method Summary collapse
-
#[](attr_key) ⇒ Object
Lookup fields in the certificate.
-
#common_name ⇒ Object
(also: #name, #cn)
The common name.
-
#country ⇒ Object
(also: #c)
The 2 letter country code of the name.
-
#email ⇒ Object
Returns the email if present in the name.
-
#initialize(name) ⇒ Name
constructor
Initializes the Name object with the underlying OpenSSL Name object.
-
#locality ⇒ Object
(also: #l)
The locality.
- #method_missing(method) ⇒ Object
-
#organization ⇒ Object
(also: #o, #organisation)
The Organization.
-
#organizational_unit ⇒ Object
(also: #ou, #organisational_unit)
The Organizational Unit.
-
#state ⇒ Object
(also: #st, #province)
The state or province code.
-
#to_s ⇒ Object
Returns the full name object in classic horrible X500 format.
Constructor Details
#initialize(name) ⇒ Name
Initializes the Name object with the underlying OpenSSL Name object. You generally do not need to use this.
Rather use the Certificates subject or issuer methods.
337 338 339 340 341 342 343 344 345 346 |
# File 'lib/ezsig.rb', line 337 def initialize(name) @name=name @attributes={} name.to_s.split(/\//).each do |field| key, val = field.split(/=/,2) if key @attributes[key.to_sym]=val end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
419 420 421 |
# File 'lib/ezsig.rb', line 419 def method_missing(method) self[method] end |
Instance Method Details
#[](attr_key) ⇒ Object
Lookup fields in the certificate.
415 416 417 |
# File 'lib/ezsig.rb', line 415 def [](attr_key) @attributes[attr_key.to_sym] end |
#common_name ⇒ Object Also known as: name, cn
The common name. For SSL this means the domain name. For personal certificates it is the name.
406 407 408 |
# File 'lib/ezsig.rb', line 406 def common_name self[:CN] end |
#country ⇒ Object Also known as: c
The 2 letter country code of the name
364 365 366 |
# File 'lib/ezsig.rb', line 364 def country self[:C] end |
#email ⇒ Object
Returns the email if present in the name
358 359 360 |
# File 'lib/ezsig.rb', line 358 def email self[:emailAddress] end |
#locality ⇒ Object Also known as: l
The locality
380 381 382 |
# File 'lib/ezsig.rb', line 380 def locality self[:L] end |
#organization ⇒ Object Also known as: o, organisation
The Organization
397 398 399 |
# File 'lib/ezsig.rb', line 397 def organization self[:O] end |
#organizational_unit ⇒ Object Also known as: ou, organisational_unit
The Organizational Unit
388 389 390 |
# File 'lib/ezsig.rb', line 388 def organizational_unit self[:OU] end |
#state ⇒ Object Also known as: st, province
The state or province code
371 372 373 |
# File 'lib/ezsig.rb', line 371 def state self[:ST] end |
#to_s ⇒ Object
Returns the full name object in classic horrible X500 format.
351 352 353 |
# File 'lib/ezsig.rb', line 351 def to_s @name.to_s end |