Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 270243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:58:06+00:00 2026-05-11T23:58:06+00:00

I’m digitally signing a XML document and verifying it on 2 different machines (Sign

  • 0

I’m digitally signing a XML document and verifying it on 2 different machines (Sign it at one machine and verifying on another).

I’m doing the following to verify the XML DSIG in CSharp.Net.

        public static Boolean VerifyXml(XmlDocument document)
        {
            document.PreserveWhitespace = true;
            // 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. 
            //**Earlier was getting exception here in rsaKey object**
            RSACryptoServiceProvider rsaKey = new RSACryptoServiceProvider(cspParams);

            // Create a new SignedXml object and pass it
            // the XML document class.
            SignedXml signedXml = new SignedXml(document);

            // Find the "Signature" node and create a new
            // XmlNodeList object.
            // It's guaranteed that there's always exists a signature 
            XmlNodeList nodeList = document.GetElementsByTagName("Signature");

            // Load the <signature> node.  
            signedXml.LoadXml((XmlElement)nodeList[0]);

            // Check the signature and return the result.
            bool isDone = signedXml.CheckSignature(rsaKey); //**This is returning false.**
            return isDone;
        }

Initially I was getting PermissionDenied exception when my web application tries to access the Key Container. However I’ve temporarily add the application user and IIS user to Administrator role and assigned FullTrust security policy to my web application using CasPol.

Q1: [My first question is What is the best way to over come this]?? I know assigning web application fulltrust and adding the user to administrator role is not a bright idea, even though it works

My second question is regarding the signedXml.CheckSignature(rsaKey); returning false. Now as per my understanding, since the XML document is digitally signed on a different machine the MAC used to signed it is stored on that machines KEY Container Name “XML_DSIG_RSA_KEY”, but when I tried to verify the signature on host machine a different MAC is generated and stored in container name “XML_DSIG_RSA_KEY” on host machine, hence the digital signature didn’t got verified.

Q2: Is this assumption correct?? and what is the best way to cope with this… Should I use a certificate to digitally signed the XML document and then verify it, in that case. should I need to accompany the certificate with the DSIG XML document.???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T23:58:07+00:00Added an answer on May 11, 2026 at 11:58 pm

    To answer your second question first: You want to verify the XML with the public part of the RSA key-pair that was used to sign it. So you need to either already possess (and trust) the public key on the verifying machine or to send the certificate containing the public key with the XML (it can be stored inside the XML-signature structure) and then verify that the certificate has been issued by a trusted Certificate Authority.

    To implement the first case, you can call ToXmlString(false) on the key on the sending side, store the result in a file and keep this file on the receiving side. Then on the receiving end, read the file and call:

    RSACryptoServiceProvider rsaKey = new RSACryptoServiceProvider();
    rsaKey.ImportFromXml(publicKeyFromFile);
    

    The second case can be done by obtaining a certificate, and adding it to the signature on the signing side like this:

    KeyInfo keyInfo = new KeyInfo();
    X509Certificate cert = // load certificate
    keyInfo.AddClause(new KeyInfoX509Data(cert));
    signedXml.KeyInfo = keyInfo;
    

    If the certificate is trusted, you can then verify the signature on the receiving side by just calling:

    bool isDone = signedXml.CheckSignature();
    

    To answer your first question: once you are no longer trying to access the private key store (which you were doing by calling the RSACryptoServiceProvider-constructor like you did), you should be able to run without full trust.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you set your socket to non-blocking, then writes should… May 12, 2026 at 5:04 am
  • Editorial Team
    Editorial Team added an answer Why not just call Taskbar.Show() after the call to Application.Run?… May 12, 2026 at 5:04 am
  • Editorial Team
    Editorial Team added an answer No. Its not safe. All the [dba|user|all]_xxx are views and… May 12, 2026 at 5:04 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.