有没有办法打印用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());

最佳答案

希望这可以帮助:

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);

09-30 14:50