简体   繁体   中英

How do you print a PKCS10CertificationRequest as a String?

Is there a way to print the CSR generated with PKCS10CertificationRequest class? I am struggling to see the generated request.

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

Hope this can help:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM