private byte[] getSubjectKeyId(X509Certificate cert) throws IOException {
   byte[] extvalue = cert.getExtensionValue(X509Extensions.SubjectKeyIdentifier.getId());
   if (extvalue == null) {
     return null;
   }
   ASN1OctetString str =
       ASN1OctetString.getInstance(
           new ASN1InputStream(new ByteArrayInputStream(extvalue)).readObject());
   SubjectKeyIdentifier keyId =
       SubjectKeyIdentifier.getInstance(
           new ASN1InputStream(new ByteArrayInputStream(str.getOctets())).readObject());
   return keyId.getKeyIdentifier();
 }
示例#2
0
 /**
  * Reads the value of the <code>SubjectKeyIdentifier</code> extension field of the certificate.
  *
  * @return Subject key identifier.
  */
 public SubjectKeyIdentifier readSubjectKeyIdentifier() {
   return SubjectKeyIdentifier.getInstance(read(ExtensionType.SubjectKeyIdentifier));
 }