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
-
COMPAT =
A flag for #to_s.
Breaks the name returned into multiple lines if longer than 80 characters.
ULONG2NUM(XN_FLAG_COMPAT)
-
DEFAULT_OBJECT_TYPE =
The default object type for name entries.
utf8str
-
MULTILINE =
A flag for #to_s.
Returns a multiline format.
ULONG2NUM(XN_FLAG_MULTILINE)
-
OBJECT_TYPE_TEMPLATE =
The default object type template for name entries.
hash
-
ONELINE =
# File 'ext/openssl/ossl_x509name.c', line 515
ULONG2NUM(XN_FLAG_ONELINE)
-
RFC2253 =
A flag for #to_s.
Returns an
RFC2253
format name.ULONG2NUM(XN_FLAG_RFC2253)
Class Method Summary
-
X509::Name.new ⇒ Name
constructor
Creates a new
Name
. -
.parse(str, template = OBJECT_TYPE_TEMPLATE)
Alias for .parse_openssl.
- .parse_openssl(str, template = OBJECT_TYPE_TEMPLATE) (also: .parse)
- .parse_rfc2253(str, template = OBJECT_TYPE_TEMPLATE)
Instance Method Summary
-
#<=>(other) ⇒ Integer
(also: #cmp)
Compares this
Name
withother
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
andvalue
to this name. -
#cmp(other) ⇒ Integer
Alias for #<=>.
-
#eql?(other) ⇒ Boolean
Returns true if
name
andother
refer to the same hash key. -
#hash ⇒ Integer
The hash value returned is suitable for use as a certificate's filename in a CA path.
-
#hash_old ⇒ Integer
Returns an MD5 based hash used in ::OpenSSL 0.9.X.
- #pretty_print(q)
-
#to_a ⇒ Name, ...
Returns an Array representation of the distinguished name suitable for passing to .new
-
#to_der ⇒ String
Converts the name to DER encoding.
-
#to_s ⇒ String
Returns this name as a Distinguished Name string.
Constructor Details
X509::Name.new ⇒ Name
X509::Name.new(der) ⇒ Name
X509::Name.new(distinguished_name) ⇒ Name
X509::Name.new(distinguished_name, template) ⇒ Name
Name
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.
# File 'ext/openssl/lib/openssl/x509.rb', line 152
alias parse parse_openssl
.parse_openssl(str, template = OBJECT_TYPE_TEMPLATE) Also known as: .parse
[ GitHub ]# File 'ext/openssl/lib/openssl/x509.rb', line 147
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 ]Instance Method Details
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
Alias for #<=>.
#eql?(other) ⇒ Boolean
Returns true if name
and other
refer to the same hash key.
#hash ⇒ Integer
The hash value returned is suitable for use as a certificate's filename in a CA path.
#hash_old ⇒ Integer
Returns an MD5 based hash used in ::OpenSSL 0.9.X.
#pretty_print(q)
[ GitHub ]
#to_a ⇒ Name
, ...
Returns an Array representation of the distinguished name suitable for passing to .new
#to_der ⇒ String
Converts the name to DER encoding
#to_s ⇒ String
#to_s(flags) ⇒ String
String
#to_s(flags) ⇒ String