Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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());
like image 582
user907810 Avatar asked Apr 30 '14 14:04

user907810


1 Answers

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);
like image 106
nouro Avatar answered Sep 28 '22 15:09

nouro