IIS Not Decrypting Password IN AppHost.Config

rr-4098 2,051 Reputation points
2023-09-19T17:54:28.93+00:00

We had to clone one of our web servers for offline testing. Everything worked fine except IIS was not able to decrypt the passwords in the appHost.config. I am not an IIS person, but more of server admin. What is the best way to decrypt all passwords then encrypt them again.

Windows development | Internet Information Services
Windows for business | Windows Server | User experience | Other
{count} votes

3 answers

Sort by: Most helpful
  1. Yurong Dai-MSFT 2,846 Reputation points Microsoft External Staff
    2023-09-20T06:03:26.31+00:00

    Hi @rr-4098,

    By default, IIS includes two main providers for securing properties. These providers are located in the applicationHost.config file's <configProtectedData> configuration section and are defined in the <providers> element.

    The AesProvider is specific to dealing with encryption and decryption for properties that are in the system.webServer section.

    The IISWASOnlyRsaProvider is specific to dealing with encryption and decryption for properties that are in the system.applicationHost section.

    These keys are in the iisConfigurationKey and iisWasKey key containers and are machine-specific. In a Web farm scenario, if encryption is required, then a key from one machine - usually the one that created the applicationHost.config file - is exported and brought into the other machines so that secure properties can be decrypted and used by the Web server.

    If the original machine still exists, for example the new machine is been cloned to test an upgrade, you can run the export RSA container iisConfigurationKey or iisWasKey on the original server:

    aspnet_regiis -px "iisConfigurationKey" c:\temp\iisConfigurationKey.xml -pri
    
    aspnet_regiis -px "iisWasKey" c:\temp\iis\iisWasKey.xml -pri
    

    Then run on the cloned server to import the RSA Container iisConfigurationKey or iisWasKey:

    aspnet_regiis -pi "iisConfigurationKey" c:\temp\iisConfigurationKey.xml
    
    aspnet_regiis -pi "iisWasKey" c:\temp\iis\iisWasKey.xml
    

    If importing the RSA Key Container is successful, restart IIS by running: iisreset.

    Reference documentation:

    Importing and Exporting Protected Configuration RSA Key Containers

    Dealing With Machine-specific Encrypted Properties

    Creating and Exporting an RSA Key Container


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the email notification for this thread.

    Best regards,

    Yurong Dai

    0 comments No comments

  2. rr-4098 2,051 Reputation points
    2023-09-20T19:30:03.2133333+00:00

    On my cloned server I checked the %programdata%\microsoft\crypto\RSA folderand found the keys listed with the correct permissions that match the source server. Just to be safe, I exported the RSA keys with the private key and imported them again into the cloned server. The problem is it is hard to test if this is working since the server is offline and will not be able to connect it to the network until off hours on the weekend. If this does not work, I will probably need to create a new RSA container.

    https://learn.microsoft.com/en-us/previous-versions/aspnet/yxw286t2(v=vs.100)

    0 comments No comments

  3. rr-4098 2,051 Reputation points
    2023-09-25T17:32:10.58+00:00

    I was able to resolvel my issue by copying the MachineGuid in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography registry location to the target computer. Once I did this, everything worked perfectly. Hopefully this will help someone else going forward. Thanks again for all of the help everyone..

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.