Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

https causing CryptographicException

Status
Not open for further replies.

geckoskin

Vendor
Oct 8, 2008
3
US
we developed a page for a client that returns some results from an SQL table. there is a link to download the results as a CSV file. on the live server, when connected via HTTPS, it throws an error. file downloads fine over normal HTTP.

the annoying thing is, the file downloads fine over HTTPS on our internal development server. both are running IIS 6, asp v2.0.50727, and sql 2005. the site is being served off one machine, not a server farm. <MachineKey> is being declared in web.config, with validation="SHA1". here is the code that is generating the csv file:

protected void DownloadNewReport(object sender, EventArgs e)
{
UpdateDataTable();

DataTable csvdt = new DataTable();
csvdt = dv.ToTable();

foreach (ListItem i in columnsCheckBoxList.Items)
{
if (!i.Selected)
{
csvdt.Columns.Remove(i.Value);
}
}

if (csvdt.Rows.Count > 0)
{
BaseCode.CSVWriteHelper.WriteCSVToResponse(csvdt.Rows, true, Response, SelectedReportName.Replace(" ","_") + "_" + MasterMMID + "_" + TradeDate + ".csv");
}

}


the full error report is below:

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

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: Padding is invalid and cannot be removed.]
System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast) +1547247
System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) +257
System.Security.Cryptography.CryptoStream.FlushFinalBlock() +30
System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Boolean useValidationSymAlgo) +156
System.Web.UI.Page.DecryptString(String s) +83
System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context) +148
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +362
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64



any thoughts as to what could be causing this? i am assuming it is a configuration issue with the live server, but i haven't the foggiest what it could be, and i don't have direct access to the box to poke around in it myself.
 
Did you try searching on google?
"System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed"
I found plenty of info there.
 
yah, tried google, the results i saw that involved https all seemed to center around server farms and/or specifying the machine key, which was why i mentioned those in my post.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top