SubjectPublicKeyInfo spki;
try {
spki = new SubjectPublicKeyInfo(
(ASN1Sequence) new ASN1InputStream(new ByteArrayInputStream(userPublicKey.getEncoded())).readObject());
} catch (IOException e) {
throw new CertificateExtensionException("IOException parsing user public key: "+e.getMessage(), e);
}
return new org.bouncycastle.asn1.x509.SubjectKeyIdentifier(spki);
}