None of this code has anything to do with iText.
PS: Try dropping the "SUN" parameter entirely.
--Mark Storer
Senior Software Engineer
Cardiff.com
#include <disclaimer>
typedef std::Disclaimer<Cardiff> DisCard;
-----Original Message-----
From: Gauravk Tyagi [mailto:gauravk.ty...@tcs.com]
Sent: Thursday, November 12, 2009 10:08 PM
To: Post all your questions about iText here
Subject: [iText-questions] reg: The private key generation.
Dear All,
i actually want to create my own private key and certificate which i would use
to sign an adobe eForm.but i am stucked here in even generating the key.Any
hint or guidance will be highly appreciated.
This code is giving the error as:
Exception in thread "main" java.security.NoSuchProviderException: no such
provider: SUN
at sun.security.jca.GetInstance.getService(GetInstance.java:82)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:206)
at java.security.SecureRandom.getInstance(SecureRandom.java:310)
at pack.KeyGeneration.main(KeyGeneration.java:22)
package pack;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import com.ibm.websphere.crypto.KeyPair;
public class KeyGeneration {
public static void main(String args[]) throws NoSuchAlgorithmException,
NoSuchProviderException, IOException
{
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");//here
the public/private key pair is generated for the algorithm RSA
SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");//
keyGen.initialize(1024, random);
java.security.KeyPair keyPair = keyGen.generateKeyPair();
PrivateKey privKey = keyPair.getPrivate();
PublicKey pubKey = keyPair.getPublic();
FileOutputStream fos = new FileOutputStream(new
File("C:\\privatekey.key"));
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(privKey);
oos.close();
fos.close();
fos = new FileOutputStream(new File("C:\\lpublickey.key"));
oos = new ObjectOutputStream(fos);
oos.writeObject(pubKey);
oos.close();
fos.close();
}
}
Gaurav Kumar Tyagi
Asst. System Engineer
Gautam Buddha Nagar
Noida - 201301,Up
India
____________________________________________
Experience certainty. IT Services
Business Solutions
Outsourcing
____________________________________________
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/