Encrypting connectionStrings section in .NET Core 2

Viewed 650

Traditionally I would have used the something like the following

            // Open the configuration file and retrieve 
            // the connectionStrings section.
            Configuration config = ConfigurationManager.OpenExeConfiguration(exeConfigName);

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

            if (section.SectionInformation.IsProtected)
            {
                // Remove encryption.
                section.SectionInformation.UnprotectSection();
            }
            else
            {
                // Encrypt the section.
                section.SectionInformation.ProtectSection(
                    "DataProtectionConfigurationProvider");
            }
            // Save the current configuration.
            config.Save();

Is there a method that can be used in .NET Core 2 with a ConnectionString stored in a appSettings.json?

0 Answers
Related