Hi all ,

I have this piece of code below using JDK 1.3 and BouncyCastel Provider

//some other import ... i am using bouncyCastle Provider
import javax.crypto.Cipher;
import org.bouncycastle.jce.PKCS10CertificationRequest;
import org.bouncycastle.asn1.x509.X509Name;

public class test
{
public static void main(String []args) throws Exception
{
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());


KeyStore ks=KeyStore.getInstance("JKS");

ks.load(new FileInputStream("test.keystore"),"one1234".toCharArray());


Enumeration e = ks.aliases();
X509Certificate c=null;

while(e.hasMoreElements())
{
String alias = e.nextElement().toString();
if(ks.isKeyEntry(alias))
{
c = (X509Certificate) ks.getCertificate(alias);
break;
}
}

String subject = c.getSubjectDN().getName();
X509Name xname = new X509Name(subject);

PrivateKey priv = (PrivateKey) ks.getKey("mykey","one1234".toCharArray());
PublicKey pub = (PublicKey) c.getPublicKey();

PKCS10CertificationRequest csr = new PKCS10CertificationRequest("MD5WithRSA",xname, pub,null,priv);

byte buf[] = csr.getEncoded();

FileOutputStream os = new FileOutputStream("request.crt");
OutputStreamWriter wr = new OutputStreamWriter(os);
wr.write("-----BEGIN NEW CERTIFICATE REQUEST-----\n");
wr.write(new sun.misc.BASE64Encoder().encode(buf));
wr.write("\n-----END NEW CERTIFICATE REQUEST-----\n");
wr.flush();
}

}


The coding Was OKAY and ran successfully...

The Problem is i want to get the same result as if i generate a csr using KEYTOOL utility...
BUT somehow i got different result , is it due because of signature algorithm or encoding??

Please help me ....
Thanks....

God Bless..