我可以使用以下代码将自签名证书生成为rootca。 但是,无法将其生成为中间ca。如何使用签名证书在Java中生成客户端证书?
public static String generateSelfSignedCertificate()
{
String cert = null;
try{
CertAndKeyGen keyGen=new CertAndKeyGen("RSA","SHA1WithRSA",null);
keyGen.generate(1024);
X500Name x500Name = new X500Name("CN=EXAMPLE.COM");
//Generate self signed certificate
X509Certificate[] chain=new X509Certificate[1];
chain[0]=keyGen.getSelfCertificate(new X500Name("CN=ROOT"), (long)365*24*3600);
System.out.println("Certificate : "+chain[0].toString());
cert = chain[0].toString();
}catch(Exception ex){
ex.printStackTrace();
}
return cert;
}