Problem verifing P7M file

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem verifing P7M file

p_spadafora
Hello everybody,
I sent an email wiht an attachment but i didn't reach the mailing list,
i guess is not possible send email with attachements?
The problem i have is the verification process of a .p7m file, it returns
false but it should return true as i signed the file and i am sure it is
valid.
The code i am using is the following:

CMSSignedData cms = new CMSSignedData( new FileInputStream(pathTop7m));
CertStore certs = cms.getCertificatesAndCRLs("Collection", "BC");
SignerInformationStore signers = cms.getSignerInfos();
Collection c = signers.getSigners();
Iterator it = c.iterator();
while (it.hasNext()) {
        SignerInformation signerInfo = (SignerInformation) it.next();
        SignerId signerID = signerInfo.getSID();
        Collection certCollection = certs.getCertificates(signerID);
        Iterator certIter = certCollection.iterator();
        while (certIter.hasNext()) {
                X509Certificate x509Cert = (X509Certificate) certIter.next();
        System.out.println("Signature Valid = "+signerInfo.verify(x509Cert,
"BC"));
       }
}


don't know why it return false, is someone wants to check the p7m file i
can email to him,
many thanks.

ciao