用开源库bouncycastle可以解析、具体代码
private byte[] getCSPK(byte[] csCert)
{
InputStream inStream = new ByteArrayInputStream(csCert);
ASN1Sequence seq = null;
ASN1InputStream aIn;
try
{
aIn = new ASN1InputStream(inStream);
seq = (ASN1Sequence)aIn.readObject();
X509CertificateStructure cert = new X509CertificateStructure(seq);
cert.getVersion();
ASN1Primitive publicKey = cert.getSubjectPublicKeyInfo().getPublicKey();
byte[] encodedPublicKey = publicKey.getEncoded();
byte[] eP = new byte[64];
System.arraycopy(encodedPublicKey, 5, eP, 0, eP.length);
return eP;
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}