Module: OpenSSL::X509::Extension::SubjectKeyIdentifier

Includes:
Helpers
Included in:
Certificate
Defined in:
lib/openssl/x509.rb

Instance Method Summary collapse

Methods included from Helpers

#find_extension

Instance Method Details

#subject_key_identifierObject

Get the subject’s key identifier from the subjectKeyIdentifier exteension, as described in RFC5280 Section 4.2.1.2.

Returns the binary String key identifier or nil or raises ASN1::ASN1Error.



82
83
84
85
86
87
88
89
90
91
92
# File 'lib/openssl/x509.rb', line 82

def subject_key_identifier
  ext = find_extension("subjectKeyIdentifier")
  return nil if ext.nil?

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

  ski_asn1.value
end