This post is somewhat similar to the link below. Unfortunately, I do not have enough reputation to ask a question there, so I am asking it here.
Confused on what is the correct procedure on storing passwords in Web.config for Azure deployment
The post above seems to work well if you are deploying to Azure because Azure provides a UI for you to store sensitive data, such as; passwords and keys. Thus, negating the need for an external file. However, if I am not deploying to Azure, then this functionality is assumed to not be available via other web hosting companies and so that answer does not apply.
My question is this, what is the best way to protect sensitive data both from being transmitted over the internet and from malicious users who manage to get the *.config file containing the sensitive data? Some ideas that I have though of are below.
1.) Place the sensitive data in an external file (AppSettingsSecrets.config) that is two folders up on the directory tree?
2.) Place the sensitive data in an external file (AppSettingsSecrets.config) that is in the same project, but set the file's build action to None?
3.) Place the sensitive data in the web.config file, but encrypt the section of the file that contains the sensitive data?
The reason for securing sensitive data within the *.config file itself is that in the event a malicious user manages to get the file containing the sensitive data they will be prevented from reading the sensitive data. All three options only seem to address the first question (preventing sensitive data data from being transmitted over the internet), but option 3 only seems to also address preventing malicious users who get the *.config file from reading the sensitive contents. If that is the case, then it seems like all three options are moot with respect to what file to put the sensitive data and where that file is located; just encrypt the portion of the web.config file that contains the sensitive data and move on. Am I missing something?