question

49750590 avatar image
0 Votes"
49750590 asked BruceZhang-MSFT commented

IIS upload jpg file to sftp server

Our company's development team uses IIS to upload jpg files to the sftp server. The source file is only 100Kb, but the file on sftp is 3TB. Open these files with a hexadecimal tool and find that they are all "00" completion bits. There is still the following warning log information on the IIS server. Does anyone know the reason?


Event code: 3005
Event message: 發生未處理的例外狀況。
Event time: 2022/5/3 上午 07:59:56
Event time (UTC): 2022/5/2 下午 11:59:56
Event ID: 759b13d42c26458a895abab9b4786811
Event sequence: 228
Event occurrence: 5
Event detail code: 0


Application information:
Application domain: /LM/W3SVC/1/ROOT/WebPage-1-132960094801933974
Trust level: Full
Application Virtual Path: /WebPage
Application Path: D:\IISProject\iPortalWebInterfaceV2\AppPlatform\
Machine name: ZZ-DMZ-KOUDAI47


Process information:
Process ID: 16064
Process name: w3wp.exe
Account name: IIS APPPOOL\DefaultAppPool


Exception information:
Exception type: CryptographicException
Exception message: 填補無效,而且無法移除。
於 System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)
於 System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
於 System.Security.Cryptography.CryptoStream.FlushFinalBlock()
於 System.Security.Cryptography.CryptoStream.Dispose(Boolean disposing)
於 System.IO.Stream.Close()
於 Utility.SecurityCls.Decrypt(String iInput) 於 D:\IISProject\iPortalWebInterfaceV2\Utility\SecurityCls.cs: 行 218
於 AppPlatform.Common.GetUserPhotoEncrypt.ProcessRequest(HttpContext context) 於 D:\IISProject\iPortalWebInterfaceV2\AppPlatform\Common\GetUserPhotoEncrypt.ashx.cs: 行 25
於 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
於 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
於 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Request information:
Request URL: https://www.ec.idpbg.foxconn.com:443/webpage/common/getuserphotoEncrypt.ashx?userno=LtU0nIdzO/Wd1OKAmkRrTg==role=KCWNgExCX7f4KQYL8C8LDw==
Request path: /webpage/common/getuserphotoEncrypt.ashx
User host address: 182.118.232.34
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\DefaultAppPool


Thread information:
Thread ID: 77
Thread account name: IIS APPPOOL\DefaultAppPool
Is impersonating: False
Stack trace: 於 System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)
於 System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
於 System.Security.Cryptography.CryptoStream.FlushFinalBlock()
於 System.Security.Cryptography.CryptoStream.Dispose(Boolean disposing)
於 System.IO.Stream.Close()
於 Utility.SecurityCls.Decrypt(String iInput) 於 D:\IISProject\iPortalWebInterfaceV2\Utility\SecurityCls.cs: 行 218
於 AppPlatform.Common.GetUserPhotoEncrypt.ProcessRequest(HttpContext context) 於 D:\IISProject\iPortalWebInterfaceV2\AppPlatform\Common\GetUserPhotoEncrypt.ashx.cs: 行 25
於 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
於 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
於 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


Custom event details:

windows-server-iisdotnet-aspnet-general
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You did not share what SFTP library you are using, configuration, code, or the error message in English. The community can only guess what mistakes are in the code. Since there is an CryptographicException exception perhaps there is an issue with how you've implemented RijndaelManagedTransform?

0 Votes 0 ·

Hi @49750590 ,

According to the exception message, you can focus on D:\IISProject\iPortalWebInterfaceV2\Utility\SecurityCls.cs: line 218 and D:\IISProject\iPortalWebInterfaceV2\AppPlatform\Common\GetUserPhotoEncrypt.ashx.cs: line 25. Check how it encrypt and decrypt the transmitted data. Make sure that the keys you use to encrypt and decrypt are the same. Another thing you need to check is you need to explicitly set the padding for both encryption and decryption for example: rj.Padding=PaddingMode.none .

0 Votes 0 ·

0 Answers