Parsing a Certificate Reply

The following example parses a PKCS #7-formatted certificate reply stored in a file and extracts all the certificates from it:
FileInputStream fis = new FileInputStream(filename);
CertificateFactory cf = CertificateFactory.getInstance("X.509");
Collection c = cf.generateCertificates(fis);
Iterator i = c.iterator();
while (i.hasNext()) {
	Certificate cert = (Certificate)i.next();
	System.out.println(cert);
}

This section is a short tutorial on how to use some of the major features of the JCE APIs in IBM® SDK, Java™ Technology Edition, Version 8. Complete sample programs that exercise the APIs can be found in Appendix D: Sample Programs of the Cryptography Extension Specification document.