// load the cert chain
CertificateFactory cf = CertificateFactory.getInstance("X.509");
ByteArrayInputStream bais = new ByteArrayInputStream(certChain);
Collection certCol = cf.generateCertificates(bais);
Certificate[] certs = new Certificate[certCol.toArray().length];
if (certCol.size() == 1) {
Debug.log("Single certificate; no chain", module);
bais = new ByteArrayInputStream(certChain);
Certificate cert = cf.generateCertificate(bais);