Bonjour à tous,

Je cherche à valider la signature de données PKCS7 :

- sous Netscape/Mozilla : la signature PKCS7 est généré par la fonction javascript window.crypto.signText(myText,true,"ask");

- sous IE, par l'activeX de microsoft Capicom


mystore.Open(CAPICOM_CURRENT_USER_STORE, "My", CAPICOM_STORE_OPEN_READ_ONLY);
store.Open(CAPICOM_CURRENT_USER_STORE, "AddressBook", CAPICOM_STORE_OPEN_READ_ONLY);

for (iCert = 1; iCert <= (store.Certificates.Count); iCert++)
{
mystore.Certificates.Add(store.Certificates.Item(iCert));
}

try {
var selected = mystore.Certificates.Select("Signature electronique",text);

var signer = new ActiveXObject("CAPICOM.Signer");
signer.Certificate = selected.Item(1);

var SignedData = new ActiveXObject("CAPICOM.SignedData");
SignedData.Content = text;
// sign
return SignedData.Sign(signer, true, CAPICOM_ENCODE_BASE64);
}
catch (e)
{
return e.message;
}



Et voici le code pour la vérification :

CMSSignedData signature = new CMSSignedData(new CMSProcessableByteArray( Base64.encode( URLDecoder.decode(datas,"ISO-8859-1").getBytes() )),Base64.decode(signedDatas.getBytes()));
SignerInformation signer = null;

signature.getSignedContent().write(System.out);

Collection c = signature.getSignerInfos().getSigners();
Iterator it = c.iterator();
CertStore certs= signature.getCertificatesAndCRLs("Collection","BC");
while (it.hasNext())
{
signer = (SignerInformation)it.next();

System.out.println("Signer : " + signer.getSID());
Collection certCollection = certs.getCertificates(signer.getSID());

Iterator certIt = certCollection.iterator();
X509Certificate certif = (X509Certificate)certIt.next();


isOk = signer.verify(certif, "BC");

System.out.println("Signer.content : " + new String(signer.getContentDigest()));
}

Pour les données en provenance de la fonction javascript crypto.signText(),
j'ai une exception :

org.bouncycastle.cms.CMSException: invalid signature format in message: + content hash found in signed attributes different


Et pour IE, tout se passe bien, sauf que la vérification me retourne faux.


quelqu'un a t'il déjà rencontrer ce problème?