class Ronin::Support::Crypto::Cert::Name
Represents the ‘Subject` and `Issuer` fields in a X509 Certificate.
@api semipublic
Public Class Methods
Source
# 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
Builds a X509 ‘Subject` or `Issuer` string.
@param [String, nil] common_name
The "common name" for the cert (ex: `github.com`).
@param [String, nil] email_address
The email address for the cert (ex: `admin@github.com`).
@param [String, nil] organizational_unit
The organizational unit for the cert.
@param [String, nil] organization
The organization name for the cert (ex: `GitHub, Inc.`).
@param [String, nil] locality
The locality or city for the cert (ex: `San Francisco`).
@param [String, nil] state
The state for the cert (ex: `Californa`).
@param [String, nil] province
The province for the cert.
@param [String, nil] country
The country for the cert (ex: `US`).
@return [Name]
The populated name.
Public Instance Methods
Source
# File lib/ronin/support/crypto/cert.rb, line 106 def [](oid) entries[oid] end
Finds the entry with the given OID name.
@param [String] oid
@return [String, nil]
Source
# File lib/ronin/support/crypto/cert.rb, line 115 def common_name self['CN'] end
The common name (‘CN`) entry.
@return [String, nil]
Source
# File lib/ronin/support/crypto/cert.rb, line 173 def country self['C'] end
The country (‘C`) entry.
@return [String, nil]
Source
# File lib/ronin/support/crypto/cert.rb, line 126 def email_address self['emailAddress'] end
The email address (‘emailAddress`) entry.
@return [String, nil]
@since 1.1.0
Source
# 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
The parsed entries in the name.
@return [Hash{String => String}]
Source
# File lib/ronin/support/crypto/cert.rb, line 153 def locality self['L'] end
The locality (‘L`) entry.
@return [String, nil]
Source
# File lib/ronin/support/crypto/cert.rb, line 135 def organization self['O'] end
The organization (‘O`) entry.
@return [String, nil]
Source
# File lib/ronin/support/crypto/cert.rb, line 144 def organizational_unit self['OU'] end
The organizational unit (‘OU`) entry.
@return [String, nil]
Source
# File lib/ronin/support/crypto/cert.rb, line 162 def state self['ST'] end
The state or province (‘ST`) entry.
@return [String, nil]