module OpenSSL::X509::Extension::AuthorityKeyIdentifier

Public Instance Methods

authority_key_identifier() click to toggle source

Get the issuing certificate’s key identifier from the authorityKeyIdentifier extension, as described in RFC5280 Section 4.2.1.1

Returns the binary String keyIdentifier or nil or raises ASN1::ASN1Error.

# File openssl/lib/openssl/x509.rb, line 104
def authority_key_identifier
  ext = find_extension("authorityKeyIdentifier")
  return nil if ext.nil?

  aki_asn1 = ASN1.decode(ext.value_der)
  if ext.critical? || aki_asn1.tag_class != :UNIVERSAL || aki_asn1.tag != ASN1::SEQUENCE
    raise ASN1::ASN1Error, "invalid extension"
  end

  key_id = aki_asn1.value.find do |v|
    v.tag_class == :CONTEXT_SPECIFIC && v.tag == 0
  end

  key_id.nil? ? nil : key_id.value
end