ByteArrayInputStream sbIn = new ByteArrayInputStream(cert.getEncoded());
ASN1InputStream sdIn = new ASN1InputStream(sbIn);
ByteArrayInputStream bIn = new ByteArrayInputStream(cert.getEncoded());
CertificateFactory fact = CertificateFactory.getInstance("X.509", "BC");
cert = (X509Certificate)fact.generateCertificate(bIn);
Certificate[] certs = new Certificate[1];
certs[0] = cert;
PKCS7SignedData pkcs7sd = new PKCS7SignedData(