El TecnoBaúl de Kiquenet

Kiquenet boring stories

Archive for the ‘Configuracion’ Category

Failed to decrypt using provider ‘RsaProtectedConfigurationProvider’

Posted by kiquenet en 19 mayo 2014

The error using ConfigurationManager and RsaProtectedConfigurationProvider section:

System.Configuration.ConfigurationErrorsException: Failed to decrypt using provider ‘RsaProtectedConfigurationProvider’. Error message from the provider: The RSA key container could not be opened.

The app.config file will have been encrypted using a certificate on your local machine. This certificate will not be present on the other machine. You will therefore not be able to decrypt the app.config file.

For this to work, you need to export the encryption key on your machine, then import it on the other machine. The following article demonstrates how to do that: Walkthrough: Creating and Exporting an RSA Key Container

This is the location where all of the keys are being put:

C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys

Solution

Using this command **aspnet_regiis -pa**

Open cmd Console -execute as Administrator-

    C:\Windows\system32>aspnet_regiis -pa "NetFrameworkConfigurationKey" "myDomain\myUser"
    Microsoft (R) ASP.NET RegIIS versión 4.0.30319.33440
    Utilidad de administración que instala y desinstala ASP.NET en el equipo local.
    Copyright (C) Microsoft Corporation. Todos los derechos reservados.
    Agregando ACL para el acceso al contenedor de claves RSA…
    Con éxito

Referencias:
http://stackoverflow.com/questions/16124389/failed-to-decrypt-using-provider-rsaprotectedconfigurationprovider/16126458#16126458

http://stackoverflow.com/a/8000407/206730

http://social.msdn.microsoft.com/Forums/vstudio/en-US/88b15d6b-9baa-4f4d-8942-137185bfdf56/bug-with-encrypting-configuration-file-using-rsaprotectedconfigurationprovider?forum=netfxbcl

More references:

http://stackoverflow.com/questions/7998666/asp-net-encryption-aspnet-regiis-farm

http://stackoverflow.com/a/16126458/206730
 http://connect.microsoft.com/VisualStudio/feedback/details/511835/the-rsaprotectedconfigurationprovider-sometimes-fails-when-encrypting-an-application-configuration-file

http://ryaremchuk.blogspot.com.es/2012/11/encrypting-and-decrypting-webconfig.html

Posted in .NET, Configuracion, Errores, Soporte | Etiquetado: , | Leave a Comment »

ConfigSource en sección Runtime

Posted by kiquenet en 13 noviembre 2012

El uso de configSource con la sección de configuración Runtime no parece funcionar bien.

A tener en cuenta:

So the conclusion is that (at least) the runtime section can’t be read from an external file, it will be ignored.

So the conclusion is still that the runtime section in an external file will be ignored (even if the file itself is actaully read).

La sección runtime se define de la siguiente manera:

 <section type="System.Configuration.IgnoreSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" name="runtime" allowlocation="false" />

"IgnoreSection" being registered to handle "runtime" seems to suggest that this configuration is read by other means altogether, and apparently this other handling is not take configSource-aware.

According to the documentation

http://msdn.microsoft.com/en-us/library/ms404289.aspx)

the assemblyBinding section defines a child element named <linkedConfiguration>.
This is used for "simplifying the management of component assemblies by allowing application configuration files to include assembly configuration files in well-known locations, rather than duplicating assembly configuration settings."

Ejemplo:

   <configuration><assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1"><linkedconfiguration href="file://c:\Program Files\Contoso\sharedConfig.xml"></linkedconfiguration></assemblybinding> 

Referencias:
http://world.episerver.com/Blogs/Magnus-Rahl/Dates/2011/6/Todays-gotcha-configSource-on-the-runtime-section-element/

http://social.msdn.microsoft.com/Forums/en-AU/clr/thread/7552df69-d3a0-49e4-b45f-0fa4972fa64c

http://blogs.msdn.com/b/junfeng/archive/2005/02/08/369662.aspx

Posted in .NET, Configuracion | Etiquetado: , , , | Leave a Comment »