class EzCrypto::Name

A handy ruby wrapper around OpenSSL's Name object. This was created to make it really easy to extract information out of the certificate.

Public Class Methods

new(name) click to toggle source

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.

# File lib/ezsig.rb, line 385
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

Public Instance Methods

[](attr_key) click to toggle source

Lookup fields in the certificate.

# File lib/ezsig.rb, line 463
def [](attr_key)
  @attributes[attr_key.to_sym]
end
c()
Alias for: country
cn()
Alias for: common_name
common_name() click to toggle source

The common name. For SSL this means the domain name. For personal certificates it is the name.

# File lib/ezsig.rb, line 454
def common_name
  self[:CN]
end
Also aliased as: name, cn
country() click to toggle source

The 2 letter country code of the name

# File lib/ezsig.rb, line 412
def country
  self[:C]
end
Also aliased as: c
email() click to toggle source

Returns the email if present in the name

# File lib/ezsig.rb, line 406
def email
  self[:emailAddress]
end
l()
Alias for: locality
locality() click to toggle source

The locality

# File lib/ezsig.rb, line 428
def locality
  self[:L]
end
Also aliased as: l
method_missing(method) click to toggle source
# File lib/ezsig.rb, line 467
def method_missing(method)
  self[method]
end
name()
Alias for: common_name
o()
Alias for: organization
organisation()
Alias for: organization
organisational_unit()
Alias for: organizational_unit
organization() click to toggle source

The Organization

# File lib/ezsig.rb, line 445
def organization
  self[:O]
end
Also aliased as: o, organisation
organizational_unit() click to toggle source

The Organizational Unit

# File lib/ezsig.rb, line 436
def organizational_unit
  self[:OU]
end
Also aliased as: ou, organisational_unit
ou()
Alias for: organizational_unit
province()
Alias for: state
st()
Alias for: state
state() click to toggle source

The state or province code

# File lib/ezsig.rb, line 419
def state
  self[:ST]
end
Also aliased as: st, province
to_s() click to toggle source

Returns the full name object in classic horrible X500 format.

# File lib/ezsig.rb, line 399
def to_s
  @name.to_s
end