public static String toPemFormat( X509Certificate certificate ) throws Exception {
        return String.valueOf(BEGIN_CERT) + '\n' +
            Base64.getMimeEncoder().encodeToString(certificate.getEncoded()) + '\n' +
            END_CERT + '\n';
    }
Returns the Privacy Enhanced Mail (PEM) format of a X509 certificate.

@param certificate An X509 certificate (cannot be null).
@return a PEM representation of the certificate (never null, never an empty string).
xmppserver/src/test/java/org/jivesoftware/openfire/keystore/KeystoreTestUtils.java