The class you are looking for is org.bouncycastle.openssl.jcajce.JcaPEMWriter
in bcpkix. You can use its write
method to encode all sorts of JCE interfaces (X509Certificate
, X509CRL
, PublicKey
, PrivateKey
, KeyPair
) to a PEM file.
In your case:
final JcaPEMWriter pemWriter = new JcaPEMWriter(System.out);
for (final Certificate cert : certs) {
pemWriter.write(cert);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…