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...

3/9/2009 12:54:38 PM
Gravatar
Total Posts 13

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

 Could this be a .net version issue?

If I look on the error page - I see ASP.Net version - 

Version Information: Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.3074

 

I'm not on my windows machine at this particular time, but could that be the issue?

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

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

I recommend that you don't try to populate the database on your dev machine and then upload it or restore it on production. Run setup on production and create the data on production, you can get a backup and restore it on your local machine for testing purposes, but populating on a dev machine and trying to then move the data to production is problematic. Especially if going from http://localhost/mojoportal/ to http://www.somedomain.com, the difference in url structure will cause problems.

Hope it helps,

Joe

3/9/2009 12:59:05 PM
Gravatar
Total Posts 18439

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

 

Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.3074

I think that looks correct, it doesn't change to 3.5 as you might expect it would because 3.5 .NET is really 2.0 with some things bolted on top.

Best,

Joe

3/9/2009 1:04:46 PM
Gravatar
Total Posts 13

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

Regarding not moving the db back and forth - 

Is there a best practice on how to best roll out data from a development environment to production?  

I envisioned using my dev machine to make some changes in content, and then publishing those changes by updating the database?  That just seems flexible to me.

Sorry if I haven't examined the docs as much as I should have for this kind of best practice, I'll check that out  - but as long as I have you here :) ...

3/11/2009 8:57:58 AM
Gravatar
Total Posts 18439

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

Hi,

Currently we don't have support for staged publishing from one server to another. You can create private pages to write and review content and then you can move the content to public pages after you are satified with it. A strategy like this is described at the bottom of this page.

I do have it on my roadmap to implement a more formal yet easy to use workflow/approval process and I will look into supporting staged server to server publishing at that point. I think it really needs to be at the feature level perhaps using web services to publsih from the one server to the other.

I don't think you should restore a db from dev to production because so much of the site data comes into the system from the public/production side, like user registratiosn, forum posts, product purchases, blog comments etc.

Best,

Joe

3/14/2009 10:15:27 AM
Gravatar
Total Posts 13

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

Bringing this subject up again - I went for a clean install on the web site, a blank database and the latest download of mojoportal. Here's the error I get (in medium trust mode).  One thing I didn't track - was when I ran the setup the first time, there was an error on the grey setup page - I ran it again, and everything worked, but now I'm wondering what that first error was.  I could try that again, but do you have any ideas?  Here's the error:

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

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.3074

 

 

3/14/2009 10:39:00 AM
Gravatar
Total Posts 18439

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

Hi,

This problem seems to be happening to some users with Medium Trust installations. I have a solution to prevent this problem for the next release.

For the current release I think you could work past it if you add this to Web.config:

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

then you will need to clean out all objects from the db and then visit /Setup/Default.aspx again.

This will make the initial password format clear text and avoid calling the crypto helper when it creates the admin user. I think this error is preventing the creation of the admin user.

Hope it helps,

Joe

 

3/14/2009 9:00:00 PM
Gravatar
Total Posts 13

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

FYI  - that worked.

Thanks for the follow up...

 

Dan

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