Home » Visual StudioRSS

How to correct error : System.Security.Cryptography.CryptographicException: Access is denied

Hello!

I'm running a Windows Server 2003 Standard with IIS and Microsoft .NET Framework Version:2.0.50727.3607 and ASP.NET Version:2.0.50727.3614.

After modifying some folders security rights and security configurations on the server we're now getting this error stack on one of our applications (see bellow).

I tried to modify the rights to the folder "Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys" as stated on some websites without success.

Can somebody helps me to pinpoint the origin of the problem?

Thanks,

Benoit-Pierre


Access is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Security.Cryptography.CryptographicException: Access is denied.


Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[CryptographicException: Access is denied.
]
   System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) +7714926
   System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters) +258
   System.Security.Cryptography.RSA.FromXmlString(String xmlString) +470
   Grics.LibNet.Security.LNPassPhraseCipher..cctor() +96

[TypeInitializationException: The type initializer for 'Grics.LibNet.Security.LNPassPhraseCipher' threw an exception.]
   Grics.LibNet.Security.LNPassPhraseCipher.Decrypt(String str) +0
   Grics.LibNet.Configuration.LNSqlServer.set_Password(String value) +19
   Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLNConfig.Read3_LNSqlServer(Boolean isNullable, Boolean checkType) +772
   Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLNConfig.Read4_LNSqlConfiguration(Boolean isNullable, Boolean checkType) +418
   Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLNConfig.Read29_LNConfig(Boolean isNullable, Boolean checkType) +401
   Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLNConfig.Read30_LibNet() +76

[InvalidOperationException: There is an error in the XML document.]
   System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) +665
   System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader) +30
   Grics.LibNet.Web.Internal.Configuration.LNConfigurationModule.Deserialize(XmlNode node) +67
   Grics.LibNet.Web.Internal.Configuration.LNWebConfigSectionHandler.CreateCustomConfigObject(XmlNode nodeSection) +7
   Grics.LibNet.Configuration.LNGenericWebConfigSectionHandler.Create(Object parent, Object configContext, XmlNode nodeSection) +56

[ConfigurationErrorsException: Erreur interne lors de la validation du fichier web.config, section LibNet: System.InvalidOperationException: There is an error in the XML document. ---> System.TypeInitializationException: The type initializer for 'Grics.LibNet.Security.LNPassPhraseCipher' threw an exception. ---> System.Security.Cryptography.CryptographicException: Access is denied.

   at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
   at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters)
   at System.Security.Cryptography.RSA.FromXmlString(String xmlString)
   at Grics.LibNet.Security.LNPassPhraseCipher..cctor()
   --- End of inner exception stack trace ---
   at Grics.LibNet.Security.LNPassPhraseCipher.Decrypt(String str)
   at Grics.LibNet.Configuration.LNSqlServer.set_Password(String value)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLNConfig.Read3_LNSqlServer(Boolean isNullable, Boolean checkType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLNConfig.Read4_LNSqlConfiguration(Boolean isNullable, Boolean checkType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLNConfig.Read29_LNConfig(Boolean isNullable, Boolean checkType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLNConfig.Read30_LibNet()
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)
   at Grics.LibNet.Web.Internal.Configuration.LNConfigurationModule.Deserialize(XmlNode node)
   at Grics.LibNet.Web.Internal.Configuration.LNWebConfigSectionHandler.CreateCustomConfigObject(XmlNode nodeSection)
   at Grics.LibNet.Configuration.LNGenericWebConfigSectionHandler.Create(Object parent, Object configContext, XmlNode nodeSection)]
   System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) +202
   System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) +1061
   System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) +1431
   System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission) +56
   System.Configuration.BaseConfigurationRecord.GetSection(String configKey) +8
   System.Web.HttpContext.GetSection(String sectionName) +47
   System.Web.Configuration.HttpConfigurationSystem.GetSection(String sectionName) +39
   System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey) +6
   System.Configuration.ConfigurationManager.GetSection(String sectionName) +78
   Grics.LibNet.Web.Internal.Configuration.LNConfigurationModule.Init() +87
   Grics.LibNet.Web.LNHttpModule.System.Web.IHttpModule.Init(HttpApplication applInstance) +179

[Exception: Erreur lors de l'initialisation du module LNConfigurationModule.]
   Grics.LibNet.Web.LNHttpModule.System.Web.IHttpModule.Init(HttpApplication applInstance) +482
   System.Web.HttpApplication.InitModulesCommon() +65
   System.Web.HttpApplication.InitModules() +43
   System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +729
   System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +298
   System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +289


Version Information:  Microsoft .NET Framework Version:2.0.50727.3607; ASP.NET Version:2.0.50727.3614

 

1 Answer Found

 

Answer 1

the error  comes from  'Grics.LibNet.Security.LNPassPhraseCipher which is your code or a 3rd party you use - it is not .net framework code. So you should debug it or check with the code provider why this happens
 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter