SilverFish
SilverFish

Reputation: 1106

Encrypt credentials in App.config in Visual Studio 2019 using aspnet_regiis

encrypt credentials in App.config in Visual Studio 2019

I need to Encrypt API credentials in my App.config in c# console application. I'm using .Net framework 4.7.2. I'm using aspnet_regiis.exe command-line tool provided by the .NET Framework. These are the steps I'm taking:

Opened Visual Studio with Admin rights Open the App.config file in the Visual Studio project. In the App.Config file, I want to Encrypt "authorizationHeaderValue", which is located under section under section

<configuration>
  <appSettings>
    <add key="authorizationHeaderValue" value="user:password"/>
  </appSettings>
.
.
.
</configuration>

Opened the Developer Command Prompt from Visual Studio. Navigated to C:\Windows\Microsoft.NET\Framework\v4.0.30319 (here is where aspnet_regiis.exe resides) hence:

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

Then ran the command to encrypt. App.Config resides in this directory:

aspnet_regiis -pef "authorizationHeaderValue" "C:\My Projects\ProjName"

I got the message:

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pef "authorizationHeaderValue" "C:\My Projects\ProjName"
Microsoft (R) ASP.NET RegIIS version 4.0.30319.0
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation.  All rights reserved.
Encrypting configuration section...
The configuration section 'authorizationHeaderValue' was not found.
Failed!

After doing some research, I renamed my App.config to web.config, but still getting error

The configuration section 'authorizationHeaderValue' was not found.
Failed!

I have tried giving full access to folder and files under the project folder. Right click file, properties to sure file is not readonly.

Please suggest what is wrong.

Upvotes: 0

Views: 460

Answers (0)

Related Questions