123456789_123456789_123456789_123456789_123456789_

Class: OpenSSL::X509::Name

Relationships & Source Files
Namespace Children
Modules:
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Comparable
Inherits: Object
Defined in: ext/openssl/ossl_x509name.c,
ext/openssl/ossl_x509name.c,
ext/openssl/lib/openssl/x509.rb

Overview

An X.509 name represents a hostname, email address or other entity associated with a public key.

You can create a Name by parsing a distinguished name String or by supplying the distinguished name as an Array.

name = OpenSSL::X509::Name.parse 'CN=nobody/DC=example'

name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']]

Constant Summary

Class Method Summary

Instance Method Summary

Constructor Details

X509::Name.newName X509::Name.new(der) ⇒ Name X509::Name.new(distinguished_name) ⇒ Name X509::Name.new(distinguished_name, template) ⇒ Name

Creates a new Name.

A name may be created from a DER encoded string der, an Array representing a distinguished_name or a distinguished_name along with a template.

name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']]

name = OpenSSL::X509::Name.new name.to_der

See add_entry for a description of the distinguished_name Array's contents

Class Method Details

.parse(str, template = OBJECT_TYPE_TEMPLATE)

Alias for .parse_openssl.

[ GitHub ]

  
# File 'ext/openssl/lib/openssl/x509.rb', line 146

alias parse parse_openssl

.parse_openssl(str, template = OBJECT_TYPE_TEMPLATE) Also known as: .parse

[ GitHub ]

  
# File 'ext/openssl/lib/openssl/x509.rb', line 141

def parse_openssl(str, template=OBJECT_TYPE_TEMPLATE)
  ary = str.scan(/\s*([^\/,]+)\s*/).collect{|i| i[0].split("=", 2) }
  self.new(ary, template)
end

.parse_rfc2253(str, template = OBJECT_TYPE_TEMPLATE)

[ GitHub ]

  
# File 'ext/openssl/lib/openssl/x509.rb', line 136

def parse_rfc2253(str, template=OBJECT_TYPE_TEMPLATE)
  ary = OpenSSL::X509::Name::RFC2253DN.scan(str)
  self.new(ary, template)
end

Instance Method Details

#cmp(other) ⇒ Integer #<=>(other) ⇒ Integer
Also known as: #cmp

Compares this Name with other and returns 0 if they are the same and -1 or +1 if they are greater or less than each other respectively.

#add_entry(oid, value [, type]) ⇒ self

Adds a new entry with the given oid and value to this name. The oid is an object identifier defined in ASN.1. Some common OIDs are:

C

Country Name

CN

Common Name

DC

Domain Component

O

Organization Name

OU

Organizational Unit Name

ST

State or Province Name

#cmp(other) ⇒ Integer #<=>(other) ⇒ Integer

Alias for #<=>.

#eql?(other) ⇒ Boolean

Returns true if name and other refer to the same hash key.

#hashInteger

The hash value returned is suitable for use as a certificate's filename in a CA path.

#hash_oldInteger

Returns an MD5 based hash used in ::OpenSSL 0.9.X.

#pretty_print(q)

[ GitHub ]

  
# File 'ext/openssl/lib/openssl/x509.rb', line 149

def pretty_print(q)
  q.object_group(self) {
    q.text ' '
    q.text to_s(OpenSSL::X509::Name::RFC2253)
  }
end

#to_aName, ...

Returns an Array representation of the distinguished name suitable for passing to .new

#to_derString

Converts the name to DER encoding

#to_sString #to_s(flags) ⇒ String

Returns this name as a Distinguished Name string. flags may be one of: