DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Simplest Digital Signing

04.24.2007
| 1953 views |
  • submit to reddit
        
            X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
            store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
            X509Certificate2Collection certs =
                X509Certificate2UI.SelectFromCollection(store.Certificates,
                    "Certificates", "Please select certificate to use", X509SelectionFlag.SingleSelection);

            CmsSigner cms = new CmsSigner(certs[0]);
            SignedCms sig = new SignedCms(new ContentInfo(new byte[10]));

            sig.ComputeSignature(cms, false);