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 204721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:29:34+00:00 2026-05-11T17:29:34+00:00

I have a desktop application which contains an App.config (program.exe.config at release) with clearly

  • 0

I have a desktop application which contains an App.config (program.exe.config at release) with clearly visible elements which define my WCF endpoints and WCF implementation.

I would ideally like to hide this from the users eyes, from simple hacking, view and change.

Should I: –

  1. Programmatically create and store my WCF endpoints and binding configuration in code. or;
  2. Implement some protection scheme over the App.config (if so, what, how), effectively obfuscating/encrypting these elements from public view, but understandable from my code?

I already utilise .NET Reactor to obfuscate and protect my program from reflection techniques.

Update 13-May-09 3:32 GMT+10
Alright well I managed to encrypt system.serviceModel but then it proved unusable when the app went to launch as an exception was thrown (System.TypeInitializationException: The type initializer for ‘System.ServiceModel.DiagnosticUtility’ threw an exception.)

  <system.serviceModel>
    <!-- [bindings] -->
    <bindings configProtectionProvider="DPAPIProtection">
      <EncryptedData>
        <CipherData>
          <CipherValue>AQAAANCMnd8BFdERjHoAwE/Cl+...

So there goes that idea. I’ll either ditch this idea, or set my endpoints in code which is behind encryption.

Isn’t anybody else concerned about their endpoint addresses clearly visible in config???

  • 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-11T17:29:34+00:00Added an answer on May 11, 2026 at 5:29 pm

    Protecting it from change is easier that protecting it from view.

    If it is simply change/hacking you are worried about, you can just compute a digital signature on the XML elements that comprise your unchangeable WCF settings, using your public key. If the customer changes anything, the sig won’t match.

    I don’t know a good way to protect it from view, really, because a determined person is going to be able to find out what you are doing in WCF (as the previous poster pointed out). You could make it more difficult, but that wouldn’t be preventing someone from viewing or learning the information.

    UPDATE:

    You need to use your own RSA private key for signing. Maybe you have an RSA keypair already. If not, you might generate a keypair, once, to do the signing. Like this.

            int keySize = 1024; // you choose
            byte[] key = Keys.GenerateKeyPair(keySize);
    
            RSACryptoServiceProvider rsaKey = new RSACryptoServiceProvider();
            rsaKey.ImportCspBlob(key);
    

    Once you have that, you can export and save it. For your own use, signing, you want the private key. For verification, apps will use the public key. This is how you get them.

            string PublicKeyXml = rsaKey.ToXmlString(false);
            string PrivateKeyXml = rsaKey.ToXmlString(true);
    

    Store these. If you ever want to sign something again using the same private key, get the RSA CSP with the FromXmlString() method, passing the PrivateKeyXml. If you want to verify, use FromXmlString() passing the PublicKeyXml.

    Once you have the key and the XML to be signed, you can do the signing. This happens just during packaging and deployment, when you create and finalize the configuration.

        // Sign an XML file. 
        // This document cannot be verified unless the verifying 
        // code has the key with which it was signed.
        public static void SignXml(System.Xml.XmlDocument Doc, RSA Key)
        {
            // Check arguments.
            if (Doc == null)
                throw new ArgumentException("Doc");
            if (Key == null)
                throw new ArgumentException("Key");
    
            // Create a SignedXml object.
            System.Security.Cryptography.Xml.SignedXml signedXml = new SignedXml(Doc);
    
            // Add the key to the SignedXml document.
            signedXml.SigningKey = Key;
    
            // Create a reference to be signed.
            Reference reference = new Reference();
            reference.Uri = "";
    
            // Add an enveloped transformation to the reference.
            var env = new XmlDsigEnvelopedSignatureTransform();
            reference.AddTransform(env);
    
            // Add the reference to the SignedXml object.
            signedXml.AddReference(reference);
    
            // Compute the signature.
            signedXml.ComputeSignature();
    
            // Get the XML representation of the signature and save
            // it to an XmlElement object.
            XmlElement xmlDigitalSignature = signedXml.GetXml();
    
            // Append the element to the XML document.
            Doc.DocumentElement.AppendChild(Doc.ImportNode(xmlDigitalSignature, true));
        }
    

    Then, embed the signed XML into app.config or as a string in the app, or whatever. When the app runs, you verify the signature at runtime, using the public key blob.

            // Verify the signature of the signed XML.
            RSACryptoServiceProvider rsaCsp = new RSACryptoServiceProvider();
            rsaCsp.FromXmlString(PublicKeyXml);
    
            bool isValid = VerifyXml(xmlDoc, rsaCsp);
    

    Here’s some code that does signature verification:

        // Verify the signature of an XML file against an asymmetric 
        // algorithm and return the result.
        public Boolean VerifyXml(XmlDocument Doc, RSA Key)
        {
            // Check arguments.
            if (Doc == null)
                throw new ArgumentException("Doc");
            if (Key == null)
                throw new ArgumentException("Key");
    
            // Create a new SignedXml object and pass it
            // the XML document class.
            System.Security.Cryptography.Xml.SignedXml signedXml = new SignedXml(Doc);
    
            // Find the "Signature" node and create a new XmlNodeList object.
            XmlNodeList nodeList = Doc.GetElementsByTagName("Signature");
    
            // Throw an exception if no signature was found.
            if (nodeList.Count <= 0)
            {
                throw new CryptographicException("Verification failed: No Signature was found in the document.");
            }
    
            // Though it is possible to have multiple signatures on 
            // an XML document, this app only supports one signature for
            // the entire XML document.  Throw an exception 
            // if more than one signature was found.
            if (nodeList.Count >= 2)
            {
                throw new CryptographicException("Verification failed: More that one signature was found for the document.");
            }
    
            // Load the first <signature> node.  
            signedXml.LoadXml((XmlElement)nodeList[0]);
    
            // Check the signature and return the result.
            return signedXml.CheckSignature(Key);
        }
    

    To test that your signature and verification actually does work, modify either the signature or the xml content that has been signed. You should see the verification fail. In the case of failed verification, your app might throw, or exit, or whatever.

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

Sidebar

Ask A Question

Stats

  • Questions 140k
  • Answers 140k
  • 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 Are you sure the paragraphs are truly multiple paragraphs (i.e.… May 12, 2026 at 7:54 am
  • Editorial Team
    Editorial Team added an answer If you want it to return a boolean, just do… May 12, 2026 at 7:54 am
  • Editorial Team
    Editorial Team added an answer EDIT trigger happy. you don't need to save it from… May 12, 2026 at 7:54 am

Related Questions

I work on a large C# application (approximately 450,000 lines of code), we constantly
I am developing a desktop application with a MainForm that's grown rather large. There
I have a windows mobile 5.0 application (smartphone) that contains a flat data file
In a C# desktop application, I have a customer widget which contains a text

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.