Class: RightScale::DistinguishedName

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

Overview

Build X.509 compliant distinguished names Distinguished names are used to describe 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]' }


38
39
40
# File 'lib/right_agent/security/distinguished_name.rb', line 38

def initialize(hash)
  @value = hash
end

Instance Method Details

#to_sObject

Human readable form



50
51
52
# File 'lib/right_agent/security/distinguished_name.rb', line 50

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

#to_x509Object

Conversion to OpenSSL X509 DN



43
44
45
46
47
# File 'lib/right_agent/security/distinguished_name.rb', line 43

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