Class: Ronin::Support::Crypto::Cert::Name
- Inherits:
-
OpenSSL::X509::Name
- Object
- OpenSSL::X509::Name
- Ronin::Support::Crypto::Cert::Name
- Defined in:
- lib/ronin/support/crypto/cert.rb
Overview
Represents the Subject
and Issuer
fields in a X509 Certificate.
Class Method Summary collapse
-
.build(common_name: nil, email_address: nil, organizational_unit: nil, organization: nil, locality: nil, state: nil, province: nil, country: nil) ⇒ Name
Builds a X509
Subject
orIssuer
string.
Instance Method Summary collapse
-
#[](oid) ⇒ String?
Finds the entry with the given OID name.
-
#common_name ⇒ String?
The common name (
CN
) entry. -
#country ⇒ String?
The country (
C
) entry. -
#email_address ⇒ String?
The email address (
emailAddress
) entry. -
#entries ⇒ Hash{String => String}
(also: #to_h)
The parsed entries in the name.
-
#locality ⇒ String?
The locality (
L
) entry. -
#organization ⇒ String?
The organization (
O
) entry. -
#organizational_unit ⇒ String?
The organizational unit (
OU
) entry. -
#state ⇒ String?
(also: #province)
The state or province (
ST
) entry.
Class Method Details
.build(common_name: nil, email_address: nil, organizational_unit: nil, organization: nil, locality: nil, state: nil, province: nil, country: nil) ⇒ Name
Builds a X509 Subject
or Issuer
string.
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/ronin/support/crypto/cert.rb', line 73 def self.build(common_name: nil, email_address: nil, organizational_unit: nil, organization: nil, locality: nil, state: nil, province: nil, country: nil) name = new name.add_entry("CN",common_name) if common_name name.add_entry('emailAddress',email_address) if email_address name.add_entry("OU",organizational_unit) if organizational_unit name.add_entry("O",organization) if organization name.add_entry("L",locality) if locality name.add_entry("ST",state || province) if (state || province) name.add_entry("C",country) if country return name end |
Instance Method Details
#[](oid) ⇒ String?
Finds the entry with the given OID name.
106 107 108 |
# File 'lib/ronin/support/crypto/cert.rb', line 106 def [](oid) entries[oid] end |
#common_name ⇒ String?
The common name (CN
) entry.
115 116 117 |
# File 'lib/ronin/support/crypto/cert.rb', line 115 def common_name self['CN'] end |
#country ⇒ String?
The country (C
) entry.
173 174 175 |
# File 'lib/ronin/support/crypto/cert.rb', line 173 def country self['C'] end |
#email_address ⇒ String?
The email address (emailAddress
) entry.
126 127 128 |
# File 'lib/ronin/support/crypto/cert.rb', line 126 def email_address self['emailAddress'] end |
#entries ⇒ Hash{String => String} Also known as: to_h
The parsed entries in the name.
91 92 93 94 95 |
# File 'lib/ronin/support/crypto/cert.rb', line 91 def entries @entries ||= to_a.to_h do |(oid,value,type)| [oid, value && value.force_encoding(Encoding::UTF_8)] end end |
#locality ⇒ String?
The locality (L
) entry.
153 154 155 |
# File 'lib/ronin/support/crypto/cert.rb', line 153 def locality self['L'] end |
#organization ⇒ String?
The organization (O
) entry.
135 136 137 |
# File 'lib/ronin/support/crypto/cert.rb', line 135 def organization self['O'] end |
#organizational_unit ⇒ String?
The organizational unit (OU
) entry.
144 145 146 |
# File 'lib/ronin/support/crypto/cert.rb', line 144 def organizational_unit self['OU'] end |
#state ⇒ String? Also known as: province
The state or province (ST
) entry.
162 163 164 |
# File 'lib/ronin/support/crypto/cert.rb', line 162 def state self['ST'] end |