2.2.7.9 post upgrade CryptographicException: The system cannot find the file specified

Post here for help with installing or upgrading mojoPortal pre-compiled release packages. When posting in this forum, please provide all relevant details. You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

Post here for help with installation of mojoPortal pre-compiled release packages

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.

You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

This thread is closed to new posts. You must sign in to post in the forums.
12/3/2008 3:01:46 PM
Gravatar
Total Posts 4

2.2.7.9 post upgrade CryptographicException: The system cannot find the file specified

Hi,

After upgrading to 2.2.7.9 I get the following error when I try to log in on my server hosted instance (running in medium trust). This upgrade works fine when I run locally on my laptop. The asp forums indicate that this is a CAS problem relating to access to the key store, but the RSA key should be coming from the web.config. Thanks.


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: The system cannot find the file specified.
]
System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) +1425404
System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters) +262
System.Security.Cryptography.RSA.FromXmlString(String xmlString) +465
mojoPortal.Web.Framework.CryptoHelper..cctor() +174

[TypeInitializationException: The type initializer for 'mojoPortal.Web.Framework.CryptoHelper' threw an exception.]
mojoPortal.Web.Framework.CryptoHelper.Hash(String cleanText) +0
mojoPortal.Web.mojoMembershipProvider.EncodePassword(String pass, MembershipPasswordFormat passwordFormat) +35
mojoPortal.Web.mojoMembershipProvider.ValidateUser(String userName, String password) +193
System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +160
System.Web.UI.WebControls.Login.AttemptLogin() +105
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +99
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102


 

12/3/2008 3:06:27 PM
Gravatar
Total Posts 18439

Re: 2.2.7.9 post upgrade CryptographicException: The system cannot find the file specified

It sounds like possibly not all the files made it. Possibly missing mojoEncryption.config in the root?

Hope it helps,

Joe

12/3/2008 3:45:55 PM
Gravatar
Total Posts 4

Re: 2.2.7.9 post upgrade CryptographicException: The system cannot find the file specified

Hi Joe,

Thanks for the quick response. Unfortunately this isn't the problem. I re-synced all of the files in the root folder and performed a directory compare (in Filezilla). Could it be related to this article?

http://forums.asp.net/t/983159.aspx

Thanks - Jon.

12/3/2008 3:56:44 PM
Gravatar
Total Posts 18439

Re: 2.2.7.9 post upgrade CryptographicException: The system cannot find the file specified

No, I don't think that forum post provides any help, the error is clear "The system cannot find the file specified", so either a file is missing or its looking in the wrong place. There is no ambiguity and errors do not lie.

The code is like this, so its looking in the root of the web app for this file:

string pathToConfigFile
= System.Web.Hosting.HostingEnvironment.MapPath("~/mojoEncryption.config");

I'm not confident in the resync or FileZilla compare. I would upload the files overwriting all of the existing files, I recommend do it in a few batches  as described here.

Hope it helps,

Joe

 

12/3/2008 5:13:55 PM
Gravatar
Total Posts 4

Re: 2.2.7.9 post upgrade CryptographicException: The system cannot find the file specified

Hi Joe,

I have just performed a full re-sync and I still see the same error. I will keep plugging away at this tomorrow at it's getting later in the UK.

Thanks for your help so far. Any other pointers welcomed.

Cheers - Jon.

12/4/2008 6:32:49 AM
Gravatar
Total Posts 18439

Re: 2.2.7.9 post upgrade CryptographicException: The system cannot find the file specified

If the mojoEncryption.config file exists on the server, I would open it with a text editor and verify you see an RSA Key, then I would check the file permission and make sure the web process user has read permission on the file.

Hope it helps,

Joe

12/4/2008 9:11:54 AM
Gravatar
Total Posts 4

Re: 2.2.7.9 post upgrade CryptographicException: The system cannot find the file specified

I am struggling to determine if file permissions are the issue (the RSA key exists in the file). My host provider assures me that the IIS user should have full read/write permissions but I don't have a lot of faith in them (from previous experience).

I am going to go for a clean install of 2.2.7.9 as I want to retire a number of child portals. Hopefully this will resolve the problem (without actually determining the issue)

I have another (hopefully minor) issue with my new, local install - I will post a seperate entry for this.

Thanks again, appreciated - Jon.

3/9/2009 12:19:15 PM
Gravatar
Total Posts 13

Re: 2.2.7.9 post upgrade CryptographicException: The system cannot find the file specified

Was there every any resolution to this issue?  I appear to have the same issue facing me.

I installed Mojoportal on a local machine, configured it, and then deployed to my hosting site (discountasp.net).   After the app setup on the server (noting no errors), I was able to browse through as an anonymous user.

When I try to register as a new user, or log in as an existing user, I get the error noted below.  This occurs in full-trust or medium-trust settings for mjoportal.

 

Are you convinced this issue is caused by an non-existent mojoEncryption.config file?  I can view the files on the web site, and see it there...

 

Thanks in advance for any help!

3/9/2009 12:46:29 PM
Gravatar
Total Posts 18439

Re: 2.2.7.9 post upgrade CryptographicException: The system cannot find the file specified

I'm not sure what is causing it if the file is there and readable (ie check permissions on the file) by the web process.

With the latest mojoPortal release (2.2.9.3) , I did change the default password format for the initial site to Hashed and though hashing doesn't require that RSA key, the CryptoHelper class I'm using to hash the passwords is trying to load the RSA key in its contructor. A couple of people have reported getting this error and it prevents the creation of the initial admin user thereby making it impossible to sign in.

Since the release I have resolved this in svn by just creating a hashing method on mojoMembershipProvider instead of using the one in CryptoHelper class, so I think the latest code bypasses this problem.

If you look in the mp_Users table and there is no admin user there then perhaps this is the cause.

For the 2.2.9.3 release a workaround exists I think by adding this to Web.config/user.config

<add key="InitialSitePasswordFormat" value="0" />

which will specify clear text as the password format for the intial site

then start again with an empty db or clean out all the procs and tables from the existing one, then visit setup/Default.aspx again.

You may be able to change it back to hashed afterwards, but this should get passed the error that prevents the admin user from being created during setup.

Hope it helps,

Joe

3/9/2009 12:47:56 PM
Gravatar
Total Posts 13

Re: 2.2.7.9 post upgrade CryptographicException: The system cannot find the file specified

 Here's my exact error by the way:

The system cannot find the file specified.

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: The system cannot find the file specified.


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: The system cannot find the file specified.
]
System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) +7712542
System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters) +258
System.Security.Cryptography.RSA.FromXmlString(String xmlString) +470
mojoPortal.Web.Framework.CryptoHelper..cctor() +216

[TypeInitializationException: The type initializer for 'mojoPortal.Web.Framework.CryptoHelper' threw an exception.]
mojoPortal.Web.Framework.CryptoHelper.Hash(String cleanText) +0
mojoPortal.Web.mojoMembershipProvider.EncodePassword(String pass, MembershipPasswordFormat passwordFormat) +36
mojoPortal.Web.mojoMembershipProvider.EncodePassword(String pass, SiteSettings site) +45
mojoPortal.Web.mojoMembershipProvider.ValidateUser(String userName, String password) +139
System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +60
System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +119
System.Web.UI.WebControls.Login.AttemptLogin() +115
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +101
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
 

3/9/2009 12:50:45 PM
Gravatar
Total Posts 13

Re: 2.2.7.9 post upgrade CryptographicException: The system cannot find the file specified

FYI -

I created the admin account on my "local" installation before I uploaded it to my hosting provider.  It was working fine there.   

I'll try the web config work around.  I'm not too worried about the site content at this particular time...

I'll let you know what happens...

You must sign in to post in the forums. This thread is closed to new posts.