locked
Can we encrypt sections of the appsettings.json using ASPNET_REGIIS command as we do with the asp.net app.config RRS feed

  • Question

  • User-540818677 posted

    When working with asp.net we can encrypt parts of the asp.net console application's app.config file by following these steps:-

    1) Rename the app.config to web.config >> run this command >>

    ASPNET_REGIIS -pef "<<customAppSettingsGroup>>/<<customAppSettings>>" "C:\Backups\MSE\MSE\MSE"

    2) Rename the web.config back to app.config....

    Now inside asp.net core we do not have app.config and we have the appsettings.json.. so my question is if we can encrypt parts of the appsettings.json using the above approach?

    Thanks

    Thursday, April 29, 2021 5:02 PM

All replies

  • User475983607 posted

    so my question is if we can encrypt parts of the appsettings.json using the above approach?

    No.  .NET 5 has built in features to secure configuration.  It's all in the official documentation. 

    https://docs.microsoft.com/en-us/dotnet/core/extensions/configuration

    If you really need to or just want to encrypt sections of the appsetting.json then it is up to you to write a some code.  It's pretty simple though. 

    Thursday, April 29, 2021 7:19 PM
  • User-540818677 posted

    johnjohn123123

    so my question is if we can encrypt parts of the appsettings.json using the above approach?

    No.  .NET 5 has built in features to secure configuration.  It's all in the official documentation. 

    https://docs.microsoft.com/en-us/dotnet/core/extensions/configuration

    If you really need to or just want to encrypt sections of the appsetting.json then it is up to you to write a some code.  It's pretty simple though. 

    Thanks for your help and info.. but can you provide me with the code with encrypt the appsetting.json?

    Thursday, April 29, 2021 10:20 PM
  • User475983607 posted

    Thanks for your help and info.. but can you provide me with the code with encrypt the appsetting.json?

    I provided sample code in another one of your posts.

    https://forums.asp.net/t/2168453.aspx

    Friday, April 30, 2021 10:42 AM
  • User503812343 posted

    you can use JsonConfigurationProvider  to configure appsettings json file data

    https://www.extutorial.com/en/share/362499

    Friday, April 30, 2021 11:53 AM