Module: OpenSSLExtensions::X509::Request
- Defined in:
- lib/openssl-extensions/x509/request.rb
Overview
Extends OpenSSL::X509::Request with shortcut methods.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Equality is tested by comparing the generated PEM signatures.
-
#challenge_password? ⇒ Boolean
Returns
true
if the signing request were generated with a challenge password. -
#hash ⇒ Object
Override the default Object#hash to identify uniqueness of the Request.
-
#strength ⇒ Object
Returns the bit strength of the public key used for the signing request.
-
#subject_alternative_names ⇒ Object
(also: #sans)
Returns a collection of subject alternative names requested.
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Equality is tested by comparing the generated PEM signatures.
12 13 14 |
# File 'lib/openssl-extensions/x509/request.rb', line 12 def ==(other) to_pem == other.to_pem end |
#challenge_password? ⇒ Boolean
Returns true
if the signing request were generated with a challenge password.
21 22 23 |
# File 'lib/openssl-extensions/x509/request.rb', line 21 def challenge_password? !read_attributes_by_oid('challengePassword').nil? end |
#hash ⇒ Object
Override the default Object#hash to identify uniqueness of the Request. This uses a hash of the PEM.
29 30 31 |
# File 'lib/openssl-extensions/x509/request.rb', line 29 def hash to_pem.hash end |
#strength ⇒ Object
Returns the bit strength of the public key used for the signing request.
42 43 44 |
# File 'lib/openssl-extensions/x509/request.rb', line 42 def strength public_key.n.num_bits end |
#subject_alternative_names ⇒ Object Also known as: sans
Returns a collection of subject alternative names requested. If no alternative names were requested, this returns an empty set.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/openssl-extensions/x509/request.rb', line 50 def subject_alternative_names @_subject_alternative_names ||= begin if attribute = read_attributes_by_oid('extReq', 'msExtReq') set = OpenSSL::ASN1.decode(attribute.value) seq = set.value.first if sans = seq.value.collect { |asn1ext| OpenSSL::X509::Extension.new(asn1ext).to_a }.detect { |e| e.first == 'subjectAltName' } sans[1].gsub(/DNS:/,'').split(', ') else [] end else [] end end end |