Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7682921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:40:42+00:00 2026-05-31T18:40:42+00:00

We want to encrypt all our web app configuration files that we deploy to

  • 0

We want to encrypt all our web app configuration files that we deploy to a server. We’d prefer to do this as a step in our build process and include the pre-encrypted files inside the MSI.

This means that our build server (encryptor) and production server (decryptor) need the same keys. So I’m trying to do a very basic test for now. Encrypt a Web.Config on MachineA – Decrypt it on MachineB. Here’s what I’ve tried to test so far

Create a new RSA Key Pair Container on my local pc.

aspnet_regiis -pc "MyContainer" -exp

Give ACL Permissions to me & the NetworkService users.

aspnet_regiis -pa "MyContainer" "MyDomain\My.Account"
aspnet_regiis -pa "MyContainer" "NT AUTHORITY\NETWORK SERVICE"

Export that key pair to an xml file

aspnet_regiis -px "MyContainer" C:\MyContainer.xml -pri

Copy that file to another pc & import it

aspnet_regiis -pi "MyContainer" C:\MyContainer.xml

Give my colleague & his machines NetworkService user permissions on the newly imported file

aspnet_regiis -pa "MyContainer" "MyDomain\My.Colleague"
aspnet_regiis -pa "MyContainer" "NT AUTHORITY\NETWORK SERVICE"

Next, I created a very simple web.config on my local machine.

<?xml version="1.0"?>
<configuration>
    <appSettings>
        <add key="SecretKey" value="ValueWeWantToHide" />
    </appSettings>
    <configProtectedData>
        <providers>
            <add name="SampleProvider"
                 type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
                 keyContainerName="MyContainer"
                 useMachineContainer="true" />
        </providers>
    </configProtectedData>
</configuration>

I can quite easily encrypt & decrypt the appSettings section here using the commands. They encrypt & decrypt successfully and the encrypted section is marked withe correct provider after encryption (<appSettings configProtectionProvider="RsaProtectedConfigurationProvider">)

aspnet_regiis -pef appSettings D:\testapp
and
aspnet_regiis -pdf appSettings D:\testapp

However when I copy the encrypted web.config to my colleagues PC, and attempt to decrypt it with the command above, the decryption fails. It gives a very unhelpful error

Failed to decrypt using provider 'RSAProtectedConfigurationProvider'. Error message from provider: Bad Data

And now I’m stuck. I’ve found a couple of similar issues on SO but nothing concrete that specifically solved their problems. Have I missed a step somewhere. I assume my key setup is valid since I can locally encrypt/decrypt. Is it possible I’ve cocked-up the key import or missed some step on my colleagues machine. Any help appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:40:43+00:00Added an answer on May 31, 2026 at 6:40 pm

    You are encrypting/decripting using the default provider on your machine (this will be different for each machine).

    You need to specify the provider:

    aspnet_regiis -pef appSettings D:\testapp -prov "SampleProvider"
    

    On your colleagues machine:

    aspnet_regiis -pdf appSettings D:\testapp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Any section in my web.config file that I want to encrypt I run this
I want to develop an application that encrypt all my conversations that I have.
I want to be able to encrypt all the data that I save in
I want to encrypt few files using python what is the best way I
I want to compress some files (into the ZIP format) and encrypt them if
Is there any javascript function that can encrypt data: For example i want to
I want to encrypt some server data using .NET's RSACryptoServiceProvider and decrypt it when
I'm writing a program that, using Rijndael, will encrypt and decrypt files/folders using a
I've inherited a web app that I've just discovered stores over 300,000 usernames/passwords in
I have a site that needs to encrypt and store binary files that are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.