SignedCms.ComputeSignature() gives "The recipient certificate is not specified" exception

The following code gives:

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Security.dll
Additional information: The recipient certificate is not specified.

SignedCms cmsMsg;
ContentInfo cInfo;
byte[] content;

content = new byte[] { 0, 1, 1, 2, 4, 6, 6, 23, 123 };
cInfo = new ContentInfo(content);
cmsMsg =
new SignedCms(SubjectIdentifierType.IssuerAndSerialNumber, cInfo, false);
MessageBox.Show(Environment.UserInteractive.ToString());
cmsMsg.ComputeSignature();

What do I need to do to make it pop a certificate selection window and proceed with signing Why and where do I need to provide the recipient certificate

Thanks a lot for your help.

Manoj K Srivastava





Answer this question

SignedCms.ComputeSignature() gives "The recipient certificate is not specified" exception

  • lonepalm

    Hi Manoj,

    You can use the overload of ComputeSignature which takes a CmsSigner and a slient flag:

    cmsMsg.ComputeSignature(new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, false);

    -Shawn



  • SignedCms.ComputeSignature() gives "The recipient certificate is not specified" exception