Securing the connection string in Windows Azure and web.config

I encrypt the connection string in web.config as described here:
http://blogs.msdn.com/b/sqlazure/archive/2010/09/07/10058942.aspx
published in Azure and everything works as expected.

BUT now I ran into a problem for my local development, where I work against a local database, where I do not need to encrypt the connection string.
My local development set up as a debug configuration, and I tried to replace (convert) the encrypted connections section in web.config as follows:

<connectionStrings configProtectionProvider="CustomProvider">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
 ...
</EncryptedData>

with a regular unencrypted section on web.config.debug

<connectionStrings>
<add name="ApplicationServices" connectionString="data source=localhost...
</connectionStrings>

xdt: Transform = "Insert", web.config.
Parser: "EncryptedData" - .

EncryptedData web.config.debug ?

+3
2

... ? .cscfg, - IIS.

0

, .csfg ( DLL):

public class MyContext : DbContext
{
    private MyContext(string connString)
        : base(connString)
    {
    }

    public static MyContext GetMyContext()
    {
        string dbConnString = CloudConfigurationManager.GetSetting("MyDbConnectionString");

        return new MyContext(decrypt(dbConnString));
    }
}
-1

Source: https://habr.com/ru/post/1777877/


All Articles