creating X.509 certificate programming without BouncyCastle .
843811Dec 6 2006 — edited Dec 6 2006I have received the certificate but I could not understand how to
create the file with correct structure like keytool utility created ?
>>
import sun.security.x509.*;
import java.security.*;
import javax.security.cert .*;
public class GenCert
{
public static void main(String[] args)throws Exception
{
CertAndKeyGen cakg = new CertAndKeyGen("RSA", "MD5WithRSA");
cakg.generate(1024);
PublicKey publicKey = cakg.getPublicKey();
System.out.println(publicKey);
PrivateKey privateKey = cakg.getPrivateKey();
System.out.println(privateKey);
X500Name name = new X500Name("One", "Two", "Three", "Four", "Five", "Six");
System.out.println(name);
X509Cert cert = cakg.getSelfCert(name, 2000000);
System.out.println("cert: "+cert);
X509Certificate certificate = X509Certificate.getInstance(cert.getSignedCert());
}
}