This is a migrated thread and some comments may be shown as answers.

v2017.2.711.45 Error occurred during a cryptographic operation

6 Answers 1309 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 01 Sep 2017, 02:59 PM

Hi,

We've downloaded the latest version of the Telerik libraries - 2017.2.711.45 - and when we drop them into our web application we get the error

Error occurred during a cryptographic operation

with the stack trace pasted at the end of this message in our log files.

The error itself is pretty generic and suggested fixes include clearing the browser cache or tokens from the UserTokenCaches table. However, none of these solutions is working for us, so we've had to do a bit more digging.

What we've discovered is that this error is occuring on any page that uses the RadAsyncUpload control (we're not sure that it's only this control but other Telerik controls seem to be fine). It only happens with the 2017.2.711.45 libraries - if we copy back in the 2017.2.503.45 libraries our web application works again as normal.

We've tried recreating the problem in a simple web application but we can't and our real web application is far too complex to whittle down to demonstrable size.

Any help would be appreciated.

Stephen.

 

 

2017-09-01 15:49:08,552 [33] [Admin] [pftilg0judh5r3uukzo3cyew] [(null)] ERROR UI.Web.Global - Application_Error : Unhandled exception.
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Security.Cryptography.CryptographicException: Error occurred during a cryptographic operation.
   at System.Web.Security.Cryptography.HomogenizingCryptoServiceWrapper.HomogenizeErrors(Func`2 func, Byte[] input)
   at System.Web.Security.Cryptography.HomogenizingCryptoServiceWrapper.Protect(Byte[] clearData)
   at System.Web.Security.MachineKey.Protect(ICryptoServiceProvider cryptoServiceProvider, Byte[] userData, String[] purposes)
   at System.Web.Security.MachineKey.Protect(Byte[] userData, String[] purposes)
   at Telerik.Web.UI.CryptoService.EncryptWithMachineKey(String clearText)
   at Telerik.Web.UI.CryptoService.Encrypt(String plainString)
   at Telerik.Web.UI.RadAsyncUpload.DescribeComponent(IScriptDescriptor descriptor)
   at Telerik.Web.UI.RadWebControl.Telerik.Web.IControl.DescribeComponent(IScriptDescriptor descriptor)
   at Telerik.Web.UI.ScriptRegistrar.GetScriptDescriptors(Control control)
   at Telerik.Web.UI.RadWebControl.GetScriptDescriptors()
   at Telerik.Web.UI.RadWebControl.System.Web.UI.IScriptControl.GetScriptDescriptors()
   at System.Web.UI.ScriptControlManager.RegisterScriptDescriptors(IScriptControl scriptControl)
   at Telerik.Web.UI.RadWebControl.RegisterScriptDescriptors()
   at Telerik.Web.UI.RadWebControl.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Control.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Control.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Control.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.UpdatePanel.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.UpdatePanel.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.PageRequestManager.RenderFormCallback(HtmlTextWriter writer, Control containerControl)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
   at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.HtmlFormWrapper.System.Web.UI.IHtmlForm.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.PageRequestManager.RenderPageCallback(HtmlTextWriter writer, Control pageControl)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Page.Render(HtmlTextWriter writer)
   at System.Web.UI.Adapters.ControlAdapter.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Page.Render(HtmlTextWriter writer)
   at System.Web.UI.Adapters.ControlAdapter.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP.members_framework_frameworklisting_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\82ed21aa\e4b970d2\App_Web_mg1k0qrw.1.cs:line 0
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

 

6 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 04 Sep 2017, 08:53 AM

Hi Stephen,

The error is quite generic and is thrown by the .NET methods we use for encryption (hence, the final lines of the stack trace pointing to the System.Web.Security.Cryptography namespace/class and seems to go through using the machine key for encrypting.

What I can suggest you try is:

  • Make sure you have the three Telerik-specific encryption keys (see the Mandatory Additions to the web.config article). The idea is to use those keys instead of fall back to the machine key.
  • See if you are running in Medium Trust. If so, try switching for Full Trust for a bit (if you have a suitable staging environment) to see if this is the cause of the problem. Some methods and reflection operations are not allowed under Medium Trust and reaching the machine key is one of them.
  • Make sure you are not adding the RadAsyncUpload to the page during a callback. You can add IScriptControl instances (such as our controls) only during postbacks (including partial postbacks), but not during callbacks.
  • If you are using RadScriptManager, try either setting its EnableScriptCombine property to false, or using the Telerik scripts CDN.
  • If this is not urgent, wait for the upcoming R3 2017 release (planned for mid-September) that will contain a fix for a concurrency issue under heavy loads related to the CryptoService. If you open a private support ticket, I could send you an internal build with it that you could test with.

 

Regards,

Marin Bratanov
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Stephen
Top achievements
Rank 1
answered on 04 Sep 2017, 10:39 AM

Adding the unique encryption keys seems to have solved our problem.

Thanks.

0
Chris
Top achievements
Rank 1
answered on 02 Jan 2020, 01:10 AM
Is there a way to create these keys without IIS?  I have to host a site on GoDaddy and I do not have access to that feature on their shared servers.
0
Marin Bratanov
Telerik team
answered on 02 Jan 2020, 12:21 PM

Hello Chris,

The key is a string used to seed the encryption algorithm. You don't have to generate this string on the machine that will use it. So, you can generate it from the IIS on your dev box, or with any other way you'd like, and commit it in the source control so it gets copied to the actual server.

If you have sufficient access to the shared server, you may want to encrypt the appSettings portion of the web.config, though: https://www.telerik.com/support/kb/aspnet-ajax/details/how-to-encrypt-the-telerik-appsettings-keys

 

Regards,
Marin Bratanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Allen
Top achievements
Rank 2
Iron
Veteran
answered on 30 Jun 2020, 09:09 AM

...Make sure you are not adding the RadAsyncUpload to the page during a callback. You can add IScriptControl instances (such as our controls) only during postbacks (including partial postbacks), but not during callbacks....

Can you clarify what this means exactly? The control is only declared in the aspx and I never 'add' it in code as far as I know.  Under what circumstances would this occur?

Also, 

...If you are using RadScriptManager, try either setting its EnableScriptCombine property to false, ...

So is this a GLOBAL thing or specific to the page with this issue ? 

 

0
Peter Milchev
Telerik team
answered on 03 Jul 2020, 08:30 AM

Hello Allen,

For convenience and better visibility from the community, I am sharing the findings we made in the support ticket for this error. 

1) The IAsyncUpload interface properties need to be declared not explicitly(because they need the public modifier) as the VS studio IntelliSense might suggest:

Working:

public string TargetFolder { get => _targetFolder; set => _targetFolder = value; }
public string TempTargetFolder { get => _tempTargetFolder; set => _tempTargetFolder = value; }
public int MaxFileSize { get => _maxFileSize; set => _maxFileSize = value; }
public TimeSpan TimeToLive { get => _timeToLive; set => _timeToLive = value; }

Not working:

string IAsyncUploadConfiguration.TargetFolder { get => _targetFolder; set => _targetFolder = value; }
string IAsyncUploadConfiguration.TempTargetFolder { get => _tempTargetFolder; set => _tempTargetFolder = value; }
int IAsyncUploadConfiguration.MaxFileSize { get => _maxFileSize; set => _maxFileSize = value; }
TimeSpan IAsyncUploadConfiguration.TimeToLive { get => _timeToLive; set => _timeToLive = value; }

1.1) Another option is to just inherit the AsyncUploadConfiguration class instead of implementing the IAsyncUploadConfiguration interface

2) The settings that are set via the configurations(e.g. TargetFolder) do not need to be declared in the AsyncUpload also as this might lead to issues.

3) The MaxFileSize is considered "unlimited" when the value is 0, the default value. In such a case, the file size check is skipped.

Regards,
Peter Milchev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
AsyncUpload
Asked by
Stephen
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Stephen
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Allen
Top achievements
Rank 2
Iron
Veteran
Peter Milchev
Telerik team
Share this question
or