0

I have been following this article from Microsoft:

https://learn.microsoft.com/en-us/dotnet/standard/security/how-to-sign-xml-documents-with-digital-signatures

I would like to implement a feature where my clients choose a bunch of invoices, I load them in XML format, load my signature and sign it, zip the files and sent them back and do that automatically.

What I am struggling to understand is how do I import the signature itself?

        // Create a new CspParameters object to specify
        // a key container.
        CspParameters cspParams = new CspParameters();
        cspParams.KeyContainerName = "XML_DSIG_RSA_KEY";

        // Create a new RSA signing key and save it in the container. 
        RSACryptoServiceProvider rsaKey = new RSACryptoServiceProvider(cspParams);

The document is signed with this rsaKey. How can I obtain the rsaKey from my own digital signature?

grozdeto
  • 1,201
  • 1
  • 13
  • 34
  • 1
    Just to make it clear: the signature is not reusable. What you need to load is the private key and use it to sign the document. The key may reside in a certificate file, might be loaded in a cert store or might be in other format, thus loading it depends on where it is. For loading from PEM, look here: http://pages.infinit.net/ctech/20040812-0816.html. Short info about the formats: https://www.sslshopper.com/ssl-converter.html – ZorgoZ Oct 18 '19 at 13:36
  • The Digital Signature solution depends on 3 things. a) Source of Document or Content b) Source of Digital Certificate (Private Key) c) Source of Trigger to Sign. Please refer to SO Answer https://stackoverflow.com/a/55676351/9659885 if you are looking to sign in Browser. To sign from desktop applications, use functions available in System.Cryptography – Bharat Vasant Oct 19 '19 at 05:59
  • Bharat thank you for your detailed answer. I would like to browse for a signature and use that to sign my documents. I have used System.Cryptography but the idea is to sign it with our company's digital signature as a proof that is us. – grozdeto Oct 21 '19 at 06:36

0 Answers0