Bad Data - CryptographicException

Author Message
 Posted 11/13/2013 5:22:54 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 10/9/2019 3:01:48 AM
Posts: 2, Visits: 1,671
We have installed the ES on an IIS 7 server in a subdirectory. We have configured the Datasources and web.config files and are getting the following error when we run client code. We have a second server configured in the root of www on another server that functions correctly from same client code. Are there any special configurations that we need to do to run from a directory on the server(wwwroot/ES)? Web.config ?




CryptographicException
  Bad Data.



Source     : mscorlib

Stack Trace: 
   at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
   at System.Security.Cryptography.Utils._DecryptData(SafeKeyHandle hKey, Byte[] data, Int32 ib, Int32 cb, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode PaddingMode, Boolean fDone)
   at System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
   at System.Security.Cryptography.CryptoStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.Compression.DeflateStream.Read(Byte[] array, Int32 offset, Int32 count)
   at System.IO.Stream.ReadByte()
   at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
   at System.IO.BinaryReader.ReadBoolean()
   at MicroFour.StrataFrame.Data.Enterprise.BaseResults.ReadDataFromStream(BinaryReader Reader)
   at MicroFour.StrataFrame.Data.Enterprise.ExecuteDataTableResults.ReadDataFromStream(BinaryReader Reader)
   at MicroFour.StrataFrame.Data.Enterprise.EnterpriseDataSourceItem.SendRequestCore(BaseParams Params, RemoteDataSourceCommand Command)
   at MicroFour.StrataFrame.Data.Enterprise.EnterpriseDataSourceItem.ᜀ(DbCommand A_0, Boolean A_1, String A_2)
   at MicroFour.StrataFrame.Data.Enterprise.EnterpriseDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)
   at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(DbCommand Command, Boolean RegisterNotification)
   at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(DbCommand CommandToExecute)
   at MicroFour.StrataFrame.Security.BusinessObjects.SFSPreferencesBO.FillAll(Int32 ProjectPK)
   at MicroFour.StrataFrame.Security.BusinessObjects.SFSPreferencesBO.RetrieveSecurityPreferences()
   at CADApplication.AppMain.InitApplication(InitializingApplicationEventArgs e) in C:\EZ911NET\CADApplication\CADApplication\AppMain.vb:line 267
   at MicroFour.StrataFrame.Application.StrataFrameApplication.Raise_InitializingApplication(InitializingApplicationEventArgs e)
   at MicroFour.StrataFrame.Application.StrataFrameApplication.RunApplication()
   at CADApplication.AppMain.Main() in C:\EZ911NET\CADApplication\CADApplication\AppMain.vb:line 41
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
   at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
   at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
   at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
   at System.Activator.CreateInstance(ActivationContext activationContext)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
Post #32282
Add to Twitter Add to Facebook
 Posted 11/13/2013 5:55:23 AM
StrataFrame Developer

StrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame Developer

Group: StrataFrame Developers
Last Login: 5/16/2018 3:20:37 AM
Posts: 2,982, Visits: 2,482
The "Bad data" exception always comes from having mismatched encryption keys and vectors on the 2 ends of the connection.  The byte arrays for the IVs and the keys have to match exactly.  Check your configuration file and the client side code where you set the values and make sure they line up.
Post #32284
Add to Twitter Add to Facebook
 Posted 11/13/2013 7:08:51 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 10/9/2019 3:01:48 AM
Posts: 2, Visits: 1,671
Ben,

Thanks for the quick reply

    I have not changed the default values as yet , I have included the code to verify that they are the same. Is there any other reason you can think of for this problem. This is the SDK version of the ES server that we are having problems with. Like I said, we are running this from a subfolder on IIS(wwwroot\ES).

Thanks in Advance

Client Side Code



  '-- Configure the compression and encryption (optional)   
                dsComm.IsCompressed = True 
                dsComm.IsEncrypted = True 
                dsComm.EncryptionKey = New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4} 
                dsComm.EncryptionVector = New Byte() {1, 2, 3, 4, 5, 6, 7, 8}






Server Side Code



<IsEncrypted>True</IsEncrypted>
  <IsCompressed>True</IsCompressed>
  <EncryptionKey>1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4</EncryptionKey>
  <EncryptionVector>1,2,3,4,5,6,7,8</EncryptionVector>
  <TransactionTimeout>3600</TransactionTimeout>




Tags:
Post #32288
Add to Twitter Add to Facebook
 Posted 11/13/2013 11:13:52 AM
Strategic Support Team Member

Strategic Support Team MemberStrategic Support Team MemberStrategic Support Team MemberStrategic Support Team MemberStrategic Support Team MemberStrategic Support Team MemberStrategic Support Team MemberStrategic Support Team MemberStrategic Support Team Member

Group: StrataFrame MVPs
Last Login: 6/15/2019 1:08:46 AM
Posts: 1,920, Visits: 21,109
Hi Tim.

Try checking if the MicroFour StrataFrame Enterprise DLLs on the client are on the same version as the ones installed on the server.
Post #32291
Add to Twitter Add to Facebook


Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.