0

I encypted the appconfig like this , on my computer works well but on a network doesn't work

Configuration config = ConfigurationManager.OpenExeConfiguration(exeConfigName);

            ConnectionStringsSection section =
            config.GetSection("connectionStrings")
            as ConnectionStringsSection;

            if (!section.SectionInformation.IsProtected)
            {
                section.SectionInformation.ProtectSection(
                    "DataProtectionConfigurationProvider");

                config.Save();
                ConfigurationManager.RefreshSection("connectionStrings");


            }
Julian
  • 33,915
  • 22
  • 119
  • 174

1 Answers1

0

DataProtectionConfigurationProvider is machine-dependent. You can't encrypt it on your workstation and expect it to work on the server by default. You could use RsaProtectedConfigurationProvider and export the keys as needed. Or just encrypt it on the server itself.

See this related SO Question

Community
  • 1
  • 1
stephen.vakil
  • 3,492
  • 1
  • 18
  • 23
  • could you tell how to import the keys?? – Suzume Himura Sep 30 '16 at 16:48
  • [Here's one way](http://stackoverflow.com/questions/26294226/encrypt-and-deploy-app-config) – stephen.vakil Sep 30 '16 at 17:16
  • in the application I use c# linq do you think the firt method is the best than the other that said "In a connected and client/server scenario I propose you a solution that I have adopted in a wide network is of not distribute connection string in app.config but of require the connection's information at a service that can be an web service or a RESTful service after the user authentication." – Suzume Himura Sep 30 '16 at 17:41
  • another question: if i do the encrypt like the first method I always have to shared the appconfig?Because the application is used on a network (just one installer) – Suzume Himura Sep 30 '16 at 17:44