If someone unauthorized gets access to the server, well, stealing secrets, say, database connection strings, is only a small part of the problem (@Dmitry answer).
Since you need better control over sensitive data or configuration, it is perfectly normal to deviate from the usual appsettings.json approach.
You can take secrets, encrypt them asymmetrically with a server certificate, save them in a separate file (it could be another .json file, for that matter), then read the file and decrypt the secrets at startup / on each network request. Thus, secrets are almost as secure as server certificate / private key.
Another option: symmetrically encrypt secrets and pass the password to the web application at startup so that it can decrypt the secrets. When the process on which the web application is running restarts, you must re-submit the password (you can use a separate computer to periodically submit it or so).
Also see Data Protection in the ASP.NET Kernel , Data Protective Patterns .
Sometimes long and cryptic passwords or just obfuscating a person-friendly password are enough. That is, just protecting from eavesdropping. For example, someone sitting next to the administrator will not be able to read and remember a chain of clearly random characters.
turdus-merula
source share