【发布时间】:2025-12-21 01:25:17
【问题描述】:
我有以下问题,我在 SQL Server 2005 的varbinary(max) 列中插入了一个 p7m 文件。
当我从经典的 asp 页面下载时,我尝试使用以下 vbscript 代码:
Dim sSql, oCmd, nomeric
Set oCmd = server.CreateObject("ADODB.Command")
Set oCmd.ActiveConnection = OBJdbConnection
oCmd.CommandType = adCmdText
sSql = "SELECT fileP7m FROM tabella "
Response.ContentType = "application/pkcs7-mime"
Response.AddHeader "Content-Disposition", "attachment; filename=" & nomeric
oCmd.CommandText = sSql
oCmd.Properties("Output Stream").Value = Response
oCmd.Execute , , 1024
Set oCmd = nothing
文件下载正确,可以正常用Adobe Acrobat打开,但是如果我将文件提交到网站验证数字签名,它会失败,而原始文件运行良好。
如果我打开用notepad++下载的文件,原来的第一个包含一些非常奇怪的字符,比如中文或印度,我真的不知道。让我以这种方式转换文件 p7m 的错误在哪里?为什么无法验证数字签名?
谢谢 最好的问候。
为了完整起见,我还编写了将文件插入数据库的方式。
pContent 是包含整个文件 p7m 的字符串。
Dim currFileStream, oCmd, i
SET oCmd = server.CreateObject ("ADODB.Command")
SET currFileStream = server.CreateObject ("ADODB.Stream")
currFileStream.Type = 2
currFileStream.Open
For i = 1 To Len(pContent)
currFileStream.WriteText ChrB(Asc(Mid(pContent, i, 1)))
Next
oCmd("@fileAttached").AppendChunk currFileStream.Read(currFileStream.Size)
oCmd.Parameters.Append oCmd.CreateParameter("@fileAllegato", adLongVarBinary, adParamInput, currFileStream.Size)
一个存储过程在fileAttached列中运行插入。
【问题讨论】: