在开始下载到客户端的 Web 浏览器之前对 .NET 程序集进行代码签名

发布于 2024-10-01 14:41:34 字数 498 浏览 1 评论 0原文

我使用signtool.exe 对通过调用命令行的C# 自动生成的可下载内容进行数字签名,然后将文件流式传输到客户端浏览器。问题是,虽然签名在网络上看起来没问题,但下载的文件似乎缺少一部分。如果您右键单击服务器上生成的文件,您会看到一个完美的签名,如果您查看证书,它会显示“此数字签名正常”。

下载的文件看起来有所不同。虽然它小了 15 个字节,但它没有损坏,但虽然问题名称完好无损,但它表示此数字签名无效。

运输过程中是否发生了什么事?我使用此代码对内容进行签名:

Response.Clear();
Response.ContentType = "应用程序/exe";
Response.AddHeader("内容处置", "文件名=" + 文件名);
Response.AddHeader("内容长度", fi.Length.ToString());
Response.TransmitFile(filePath);

提前致谢,
坦率。

I'm using signtool.exe to digitally sign auto-generated downloadable content from C# calling the command line and then stream the file to the client browser. The problem is that while the signature seems ok on the web, the downloaded file seems to be lacking a segment of it. If you right click on the generated file on the server, you see a perfectly good signature and if you view the certificate, it says that "this digital signature is OK".

The downloaded file looks different. While it's 15 bytes smaller, it's not corrupted but while the issue name is intact, it says that This digital signature is not valid.

Is something happening during transit? I'm using this code to sign the content:

Response.Clear();
Response.ContentType = "application/exe";
Response.AddHeader("content-disposition", "filename=" + filename);
Response.AddHeader("Content-Length", fi.Length.ToString());
Response.TransmitFile(filePath);

Thanks in advance,
Frank.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深海少女心 2024-10-08 14:41:35

在读取 Content-Length 标头的长度之前尝试刷新您的 FileInfo fi,它可能会在签名之前缓存旧长度。

Try to refresh your FileInfo fi before reading the length for the Content-Length header, it may be caching the old length prior to the signing or so.

一口甜 2024-10-08 14:41:34

标头中发送给客户端的响应长度是正确的还是错误(短)的?使用Fiddler或者Firebug来检查。

如果正确,但客户端未接收数据,请在 TransmitFile 之后尝试 Reponse.Flush()。我认为这可能只是迷信,但似乎很多人都这样做。

Is the response sent to the client in the headers the correct length or the wrong (short) one? Use Fiddler or Firebug to check.

If it's correct, but the client isn't receiving the data, try a Reponse.Flush() after the TransmitFile. I think that's probably just superstition, but a lot of people seem to do it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文