PKCS10certificationrequest打印为字符串

时间:2014-04-30 14:32:08

标签: java bouncycastle

有没有办法打印使用PKCS10certificationrequest类生成的CSR?我很难看到生成的请求。请帮忙。

             PKCS10CertificationRequest certRequest = new PKCS10CertificationRequest(fromByteArray);
             System.out.println("CSR string   = "+certRequest.toString()); 

             System.out.println("CSR Subject Name  = "+certRequest.getSubject().toString());
             System.out.println("CSR Subject PubkeyInfo  = "+certRequest.getSubjectPublicKeyInfo().toString());

1 个答案:

答案 0 :(得分:10)

希望这可以提供帮助:

PemObject pemObject = new PemObject("CERTIFICATE REQUEST", certRequest.getEncoded());
StringWriter str = new StringWriter();
PEMWriter pemWriter = new PEMWriter(str);
pemWriter.writeObject(pemObject);
pemWriter.close();
str.close();
System.out.println(str);