Adding attributes to pkcs7/cms signature

From: Jayant Sane (JayantSane_at_discussions.microsoft.com)
Date: 01/27/05


Date: Thu, 27 Jan 2005 11:13:03 -0800


I am using .Net 2.0 (v2.0.41115) to create a signature where I would like to
add some attributes (either signed or unsigned) to it.

However in all of the relevant classes under
System.Security.Cryptography.Pkcs namespace, they only allow you to retrieve
attributes from a signed object. Meaning I cant see a way to add them to a
signature while creating it. I have following code snippet to illustrate what
I am trying to do:

    X509Store certStore = new X509Store();
    certStore.Open(OpenFlags.ReadOnly);

    X509CertificateEx signerCert = null;
    // find the signer cert and set the above var to it..

    CmsSigner signer = new CmsSigner(signerCert);
    SignedCms signedCMS = new SignedCms(content, false);

   // what do i do to add either signed or unsigned attribute
   // to my signature???

    signedCMS.ComputeSignature(signer);
    byte[] signedData = signedCMS.Encode();
...

I know how to add attributes to signature using CryptoAPI .

TIA.
Jay



Relevant Pages

  • Re: Ability to control what tags/elements have namespaces in them
    ... You'd like any object that serializes into an _empty_ tag to have ... no xmlns declaration for xsi; however, ... except for the 'q1:' namespace preface. ... Do you mean the q1 on the Signature? ...
    (microsoft.public.dotnet.xml)
  • XMLBeans namespace problem
    ... I have a problem using namespace while validating parsed xml document ... Expected element 'Signature' instead of ... Do I have to set namespace aware or somethin like that? ...
    (comp.lang.java.programmer)
  • Unable to extract cert details in CAPICOM
    ... I need to retrieve the signer cert details from the ... signature whether it is valid or tampered. ... Iam unable to retrieve ...
    (microsoft.public.platformsdk.security)
  • Re: Delegate Question: How does it know?
    ... I can reference any method in any class in the same namespace as long ... As of .NET 2.0, the signature doesn't have ... No - when you create a delegate instance, you tell it which method you ... SimpleDelegate simpleDelegate = new SimpleDelegate; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Email signature using Outlook COM object model
    ... setting it would retrieve the signature line of an email. ... if the user has an automatic signature set up and you call MailItem.Display first. ... Author of Microsoft Outlook 2007 Programming: ...
    (microsoft.public.outlook.program_vba)