private String certificationRequestToPEM(PKCS10CertificationRequest csr) throws IOException {
        PemObject pemCSR = new PemObject("CERTIFICATE REQUEST", csr.getEncoded());

        StringWriter str = new StringWriter();
        JcaPEMWriter pemWriter = new JcaPEMWriter(str);
        pemWriter.writeObject(pemCSR);
        pemWriter.close();
        str.close();
        return str.toString();
    }
private String certificationRequestToPEM ( PKCS10CertificationRequest csr ) throws IOException { PemObject pemCSR = new PemObject ( "CERTIFICATE REQUEST" , csr . getEncoded ( ) ) ; StringWriter str = new StringWriter ( ) ; JcaPEMWriter pemWriter = new JcaPEMWriter ( str ) ; pemWriter . writeObject ( pemCSR ) ; pemWriter . close ( ) ; str . close ( ) ; return str . toString ( ) ; }
certificationRequestToPEM - Convert a PKCS10CertificationRequest to PEM
format.

@param csr The Certificate to convert
@return An equivalent PEM format certificate.
@throws IOException