Is there some high level way to write an X509Certificate into a PEM formatted string? Currently I\'m doing x509cert.encode() to write it into a DER formatted string, then ba
To build on ZZ Coder's idea, but without using the sun.misc
classes that aren't guaranteed to be consistent between JRE versions, consider this
Use Class:
import javax.xml.bind.DatatypeConverter;
Code:
try {
System.out.println("-----BEGIN CERTIFICATE-----");
System.out.println(DatatypeConverter.printBase64Binary(x509cert.getEncoded()));
System.out.println("-----END CERTIFICATE-----");
} catch (CertificateEncodingException e) {
e.printStackTrace();
}