module OpenSSLExtensions::X509::Request

Extends OpenSSL::X509::Request with shortcut methods.

Public Instance Methods

==(other) click to toggle source

Equality is tested by comparing the generated PEM signatures.

# File lib/openssl-extensions/x509/request.rb, line 12
def ==(other)
  to_pem == other.to_pem
end
Also aliased as: eql?
challenge_password?() click to toggle source

Returns true if the signing request were generated with a challenge password.

# File lib/openssl-extensions/x509/request.rb, line 21
def challenge_password?
  !read_attributes_by_oid('challengePassword').nil?
end
eql?(other)
Alias for: ==
hash() click to toggle source

Override the default Object#hash to identify uniqueness of the Request. This uses a hash of the PEM.

# File lib/openssl-extensions/x509/request.rb, line 29
def hash
  to_pem.hash
end
sans()
strength() click to toggle source

Returns the bit strength of the public key used for the signing request.

# File lib/openssl-extensions/x509/request.rb, line 37
def strength
  public_key.n.num_bits
end
subject_alternative_names() click to toggle source

Returns a collection of subject alternative names requested. If no alternative names were requested, this returns an empty set.

# File lib/openssl-extensions/x509/request.rb, line 45
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
Also aliased as: sans

Protected Instance Methods

read_attributes_by_oid(*oids) click to toggle source
# File lib/openssl-extensions/x509/request.rb, line 66
def read_attributes_by_oid(*oids)
  attributes.detect { |a| oids.include?(a.oid) }
end