certificate chain with CertificateFactory
843811May 12 2003 — edited Jul 26 2010Hi , i want to import the cert chain gived by my CA like keytool.
I try to explain better:
When i import the file returned by my CA with keytool,
the method getCertificateChain(myalias) returns 2 certificates.
I want to make the same operation using java code:
FileInputStream fis = new FileInputStream(filename);
CertificateFactory cf = CertificateFactory.getInstance("X.509");
Collection c = cf.generateCertificates(fis);
X509Certificate certs = new x509Certificate[c.size()];
Iterator i = c.iterator();
while (i.hasNext()) {
cert[num++] = (X509Certificate)i.next();
System.out.println(cert);
}
But Why the Collection size is 1 ? (I expected 2)
After when i replace the alias certificate in the keystore ,
with the method getCertificateChain i obtain only 1 cert.
Any Ideas....
How can i import the PKCS#7-formatted certificate reply ?