Wrox Programmer Forums
BOOK: Beginning Cryptography with Java
This is the forum to discuss the Wrox book Beginning Cryptography with Java by David Hook; ISBN: 9780764596339
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Cryptography with Java section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 27th, 2012, 12:07 PM
Registered User
Join Date: Nov 2012
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts
Default Create pem encoded csr file ouput

In chapter 6, PKCS10CertificationRequest

the PKCS10CertificationRequest class creates pem encoded csr line output.

To create file output, (rather than display output)

I added a following code in main();

FileOutputStream fOut = new FileOutputStream("pkcs10.req");

However, gerenated file "pkcs10.req" seems to be der encoded file rather than pem encoded one.

How can I create pem encoded Certification Request file output?
Old November 27th, 2012, 04:17 PM
dgh dgh is offline
Wrox Author
Join Date: Aug 2005
Posts: 206
Thanks: 0
Thanked 20 Times in 20 Posts

Use org.bouncycastle.openssl.PEMWriter.


Old November 27th, 2012, 06:32 PM
Registered User
Join Date: Nov 2012
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts

Thanks David.

Could give me an code example? (since I failed to generate the file through PEMWriter)

Old December 2nd, 2012, 01:08 PM
Registered User
Join Date: Nov 2012
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts

use following method
public static void pemEncodeToFile(String filename, Object obj, char[] password) throws Exception{
PEMWriter pw = new PEMWriter(new FileWriter(filename));
if (password != null && password.length > 0) {
pw.writeObject(obj, "DESEDE", password, new SecureRandom());
} else {

and call like this.

pemEncodeToFile("pkcs10.req", request, null);

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generate ouput depending on subnode value cristina.macias.614 XSLT 6 August 9th, 2011 08:03 AM
XSL: Ouput replaces dot as comma ?? elayaraja.s XSLT 2 August 19th, 2008 08:37 AM
Ouput Error phungleon C++ Programming 0 June 7th, 2007 05:53 PM
Wiered ouput exstream ASP.NET 2.0 Basics 2 May 12th, 2006 04:59 PM
helpme ! query ouput categorize by group on asp eyesonly Classic ASP Databases 0 January 23rd, 2004 04:15 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.