+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / SqlException and CryptographicException on after another on server

SqlException and CryptographicException on after another on server

5 posts, 0 answered
  1. Scott McNeany
    Scott McNeany avatar
    44 posts
    Registered:
    09 Mar 2010
    30 Sep 2010
    Link to this post
    Hello, we are experiencing an issue on some of our servers (QA and Production) in which we receive two errors one right after the other quite frequently. I will include the stack traces for both of them, but wanted to include some detail first.

    These errors only happen on ONE of our Sitefinity sites. We have 4 Sitefinity sites out on production, and several more non-Sitefinity sites in which this error does not occur. The site in which it occurs has the most traffic of any of our sites. The sever IS load-balanced, but we have a 'machineKey' already set up and that doesn't seem to change anything. If we recycle the application pool, it will remedy the issue temporarily, but it will happen again soon after. This only occurs when trying to PUBLISH content.

    Error that comes in 1st:

    System.Data.SqlClient.SqlException: Procedure or function 'sf_CmsContentBase_upd' expects parameter '@P_StreamingProviderName', which was not supplied.

    Generated: Thu, 30 Sep 2010 17:26:53 GMT

    System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlClient.SqlException: Procedure or function 'sf_CmsContentBase_upd' expects parameter '@P_StreamingProviderName', which was not supplied.
       at Nolics.ORMapper.DataProviders.SQLBlockBuilder.EndStatement(SQLCommandEventArgs args, DataRow row)
       at Nolics.ORMapper.DataProviders.SQLBlockBuilder.ExecCommandProcedure(StmtContext context, DataRow data)
       at Nolics.ORMapper.DataProviders.SQLBlockBuilder.ExecuteCommand(StmtContext context, DataRow data)
       at Nolics.ORMapper.DataProviders.SQLDataProvider.Update(DataSet updateData)
       at Nolics.ORMapper.Base.Transaction.Commit(Boolean fCleanIfSuccess)
       at Nolics.ORMapper.Base.Transaction.Commit()
       at Telerik.Cms.Engine.Data.Providers.DefaultProvider.SaveContent(IContent content, Boolean fireEvents)
       at Telerik.Cms.Engine.ContentProviderBase.SaveContent(IContent content)
       at Telerik.Cms.Engine.ContentManager.SavedStagedContent(StagedContent staged, ContentStatus status)
       at Telerik.Cms.Engine.ContentManager.PublishContent(Guid id)
       at Telerik.Cms.Engine.ContentWorkflowService.PublishContent(String providerName, Guid contenId)
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at Telerik.Workflow.CallExternalMethodActivity.Execute(WorkflowRuntime runtime)
       at Telerik.Workflow.Activity.Execute(WorkflowRuntime runtime)
       at Telerik.Workflow.EventActivity.Execute(WorkflowRuntime runtime)
       at Telerik.Workflow.WebControls.WorkflowMenu.Button_Command(Object sender, CommandEventArgs e)
       at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
       at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       --- End of inner exception stack trace ---
       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.sitefinity_admin_modules_aspx.ProcessRequest(HttpContext context)
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    


    Error that comes in 2nd:

    System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.

    Generated: Thu, 30 Sep 2010 17:26:54 GMT

    System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.
       at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)
       at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
       at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
       at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo)
       at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType)
       at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    


    Please let me know if you have any suggestions.

    Thank you,

    Scott McNeany
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Sep 2010
    Link to this post
    Hello Scott,

    1st error - Most probably you are upgrading or downgrading the project by making a request to the same database from two websites that use different version - say 3.6 ( it could be each version prior 3.7 SP3). This has downgraded the database. Then, you have made request from the website that uses Sitefinity 3.7 SP3 or SP4 dlls and you are getting the errors because of the downgrade.

    Please make sure that you do not have two websites with different versions that points to the same database. You could also check the SchemaVersion value in the tables below. The value should be set the the project version. You will find list with all versions here.

    • [sf_CmsVariables]
    • [sf_frm_Variables]
    • [sf_GC_Variables]
    • [sf_LocVariables]
    • [sf_Notif_Variables]
    • [sf_Polls_Variables]
    • [sf_Search_Variables]
    • [sf_VersVariables] 

    The 2nd error.

    "Padding is invalid" is a common issue with web resources. The fix appears to be to define a machine key in your web.config. You can find more info at the end of this blog post. This works for web garden/farms and single server scenarios. In some cases the url rewriting could lead to this errors. Your second post shows that you use url rewriting and extensionless urls. Another possible reason could be the page caching - a page is loaded and cached by the user's browser, along with the encrypted WebResource paths,  machine key changes on the server. When the user re-loads the cached version of the page, the browser uses the cached HTML with not valid  WebResource links. Another reason could be if your appdomain was recycled. When that happens the application and the machine key is set to auto, it changes. That affects the decryption of the info in the url of the resources urls (.axd).
    When you are in farm/balance you should ensure that the encryption parameters in your machineKey section are the same for both server.  Specifying the same keys on all the machines is required. If you take a look at the stack trace you will see that the System.Web.Configuration.MachineKeySection.EncryptOrDecryptData is called then RijndaelManagedTransform.DecryptData fails -Defines the configuration settings that control the key generation and algorithms that are used in encryption, decryption, and media access control (MAC) operations in Windows Forms authentication, view-state validation, and session-state application isolation. This class cannot be inherited. You could also take a look at Debugging ASP.NET 2.0 Web Resources: Decrypting the URL and Getting the Resource Name to narrow down the issue. Another useful link is http://support.microsoft.com/kb/842791/en-us
    If you use decription attribute to auto you could try switching it to EAS. If you are using a custom modules with embedded resources as images, css classes etc make sure that there are not any hardcoded values there. In case of hardcoded values use ClientScriptManager.GetWebResourceUrl Method . You could also switch the application pool if you are running under Integrated mode - switch to Classic.

    Just a reference to ScottGu's blog about this issue which says that there are two reasons for this error - An attack attempt, or what I explained above.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
     
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
     
  3. Scott McNeany
    Scott McNeany avatar
    44 posts
    Registered:
    09 Mar 2010
    30 Sep 2010
    Link to this post
    You're a wise man, Mr. Ivan. My main build of SF is version 2022, but somehow the GC_Variables and LocVariables have been replaced with 2096.

    Any idea which DLL these are generated by?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Sep 2010
    Link to this post
    Hello Scott,

    If your main project is build 2022, this is 3.7 SP1 and there is no implementation for streaming. You have another project 3.7 SP3 that uses the same database. You should check the connection string of your project and dll versions in the bin folder. You can check the dll version by using Windows Explorer properties context menu.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Scott McNeany
    Scott McNeany avatar
    44 posts
    Registered:
    09 Mar 2010
    30 Sep 2010
    Link to this post
    I've got it now. The web application is using 3.7SP1 (2022), but we have a web service that grabs content from this database as well. The last time it was deployed, the reference paths were changed to point to the 3.7SP3 (2096) DLLs, which are also in source control.

    I've corrected the issue and the database tables are now consistent with 2022 as the version.

    Thanks a bunch for your help.

    Scott McNeany
Register for webinar
5 posts, 0 answered