Class: Nanite::DistinguishedName

Inherits:
Object
  • Object
show all
Defined in:
lib/nanite/security/distinguished_name.rb

Overview

Build X.509 compliant distinguished names Distinghuished names are used to desccribe both a certificate issuer and subject.

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ DistinguishedName

Initialize distinguished name from hash e.g.:

{ 'C'  => 'US',
  'ST' => 'California',
  'L'  => 'Santa Barbara',
  'O'  => 'RightScale',
  'OU' => 'Certification Services',
  'CN' => 'rightscale.com/[email protected]' }


17
18
19
# File 'lib/nanite/security/distinguished_name.rb', line 17

def initialize(hash)
  @value = hash
end

Instance Method Details

#to_sObject

Human readable form



29
30
31
# File 'lib/nanite/security/distinguished_name.rb', line 29

def to_s
  '/' + @value.to_a.collect { |p| p.join('=') }.join('/') if @value
end

#to_x509Object

Conversion to OpenSSL X509 DN



22
23
24
25
26
# File 'lib/nanite/security/distinguished_name.rb', line 22

def to_x509
  if @value
    OpenSSL::X509::Name.new(@value.to_a, OpenSSL::X509::Name::OBJECT_TYPE_TEMPLATE)
  end
end