1
I’m trying to integrate with a webservice, which requires the message to be encrypted to PKS7 standard, but when I try to digitally sign the message, I’m getting this error:
Exception: The provider could not perform the action because the context was acquired as silent.
public static byte[] SignFile(X509Certificate2Collection certs, byte[] data)
{
try
{
ContentInfo content = new ContentInfo(data);
SignedCms signedCms = new SignedCms(content, false);
if (VerifySign(data))
{
signedCms.Decode(data);
}
foreach (X509Certificate2 cert in certs)
{
CmsSigner signer = new CmsSigner(cert);
signer.IncludeOption = X509IncludeOption.WholeChain;
signedCms.ComputeSignature(signer);
}
return signedCms.Encode();
}
catch (Exception ex)
{
throw new Exception("Erro ao assinar arquivo. A mensagem retornada foi: " + ex.Message);
}
Try to call
signedCms.ComputeSignature(signer, false)
- SOEN– Bruno Costa
Thanks, it worked, that’s right!
– João