Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Encrypt web config connections section for Entity Framework

$
0
0

I am looking for a simple solution to encrypt an application's config file, the connections section by using code behind. 

I've come across a method shown below.  I have a few questions about using it.  The source of this method came from https://visualstudiomagazine.com/articles/2009/06/11/encrypting-the-web-config-file.aspx.

Below is an encryption method contained in a separate class from the application web pages.

 Public Class clsEncrypt
Public sub Encrypt(ByVal HttpRequest As HttpRequest) Dim configFile As System.Configuration.Configuration Dim configSection As ConfigurationSection configFile = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(HttpRequest.ApplicationPath) configSection = configFile.Sections("connectionStrings") configSection.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider") configFile.Save() End sub
End Class

Will the above method encrypt the application's config file and using the entity frame work queries as below?  Each web page has multiple webmethods that interact with the database.

//below code is in a webmethod

Dim configEncrypt as new clsEncrypt

configEncrypt.Encrypt(HttpContext.Current.Request)

Dim dbconnection as New MyEntities

then linq queries query the database tables..

Will the linq queries still work after invoking the configEncrypt.Encrypt method?

Will running the above code change the application config file connections section in the application or will it encrypt contents in memory when the webmethod is called?

If the above code would work, should the method be called each time a page loads that interacts with the database, for each webmethod that interacts with the database, or both?

Are there any things I should be aware of before running the application code on a remote server?

many thanks for any input..


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>