try
{
SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(
(ASN1Sequence)new ASN1InputStream(pubKey.getEncoded()).readObject());
return (ASN1OctetString)(new SubjectKeyIdentifier(info).toASN1Object());
}
catch (Exception e)
{
throw new CertificateParsingException("Exception extracting certificate details: " + e.toString());
}