/**
   * Returns the AuthorityKeyIdentifier extension value on String format.<br>
   * Otherwise, returns <b>null</b>.<br>
   *
   * @return String
   * @throws IOException
   */
  public String getAuthorityKeyIdentifier() throws IOException {
    // TODO - Precisa validar este metodo com a RFC
    DERSequence seq =
        (DERSequence) getExtensionValue(X509Extensions.AuthorityKeyIdentifier.getId());
    if (seq == null || seq.size() == 0) {
      return null;
    }
    DERTaggedObject tag = (DERTaggedObject) seq.getObjectAt(0);
    DEROctetString oct = (DEROctetString) DEROctetString.getInstance(tag);

    return toString(oct.getOctets());
  }
 private byte[] getAuthorityKeyId(X509Certificate cert) throws IOException {
   byte[] extvalue = cert.getExtensionValue(X509Extensions.AuthorityKeyIdentifier.getId());
   if (extvalue == null) {
     return null;
   }
   DEROctetString oct =
       (DEROctetString) (new ASN1InputStream(new ByteArrayInputStream(extvalue)).readObject());
   AuthorityKeyIdentifier keyId =
       new AuthorityKeyIdentifier(
           (ASN1Sequence)
               new ASN1InputStream(new ByteArrayInputStream(oct.getOctets())).readObject());
   return keyId.getKeyIdentifier();
 }