DPE Nano Services

Encrypting secrets in appsettings.json

Some string values in appsettings.json might contain secrets like a database password in DpeLogging:ConnectionString.

These strings can be encrypted using the DpeNanoServices app from command-line.

After encrypting a string, you cannot restore its original text;
make sure you remember what is inside


Example

Before encrypting a value you might want to create a copy of the value with a different name and without secrets as reminder:

  "DpeLogging": {
...
    "__ConnectionStringBackup": "<my original value without secrets>",
    "ConnectionString": "<original value with secrets>",
...


To encrypt the value under DpeLogging:ConnectionString:

  • Open a terminal,

  • Navigate to the DpeNanoServices folder

  • Enter the following command-line

DpeNanoServices /EncryptJson:DpeLogging:ConnectionString


Afterwards the appsettings.json should look similiar to

  "DpeLogging": {
...
    "ConnectionString": "!Encrypted!:822D3D...8FF36BCFF3",
...