本文整理了Java中org.bouncycastle.asn1.x509.SubjectPublicKeyInfo.getPublicKey()
方法的一些代码示例,展示了SubjectPublicKeyInfo.getPublicKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SubjectPublicKeyInfo.getPublicKey()
方法的具体详情如下:
包路径:org.bouncycastle.asn1.x509.SubjectPublicKeyInfo
类名称:SubjectPublicKeyInfo
方法名:getPublicKey
[英]for when the public key is an encoded object - if the bitstring can't be decoded this routine throws an IOException.
[中]因为,当公钥是一个编码对象时——如果无法解码位字符串,该例程将抛出IOException。
代码示例来源:origin: stackoverflow.com
byte[] keyBytes = key.getEncoded(); // X.509 for public key
SubjectPublicKeyInfo subPkInfo = new SubjectPublicKeyInfo((ASN1Sequence)ASN1Object.fromByteArray(keyBytes));
byte[] rsaformat = subPkInfo.getPublicKey().getDEREncoded();
代码示例来源:origin: com.intrbiz.bergamot/bergamot-crypto-util
public static CertificateRequest loadCertificateRequest(Reader reader) throws IOException
{
try (PEMReader pr = new PEMReader(reader))
{
CertificationRequest req = (CertificationRequest) pr.readObject();
// get the CN
String cn = (String) ((X509Name) req.getCertificationRequestInfo().getSubject()).getValues(new DERObjectIdentifier("2.5.4.3")).get(0);
// build the key
KeyFactory kf = KeyFactory.getInstance("RSA");
PublicKey key = kf.generatePublic(new RSAPublicKeySpec(
((ASN1Integer)((DERSequence) req.getCertificationRequestInfo().getSubjectPublicKeyInfo().getPublicKey()).getObjectAt(0)).getValue(),
((ASN1Integer)((DERSequence) req.getCertificationRequestInfo().getSubjectPublicKeyInfo().getPublicKey()).getObjectAt(1)).getValue()
));
return new CertificateRequest(cn, key);
}
catch (NoSuchAlgorithmException | InvalidKeySpecException e)
{
throw new IOException("Failed to parse certificate request", e);
}
}
内容来源于网络,如有侵权,请联系作者删除!