简体   繁体   English

通过HTTPS下载的Android 2.2和2.3 PDF文件似乎已经破裂

[英]Android 2.2 and 2.3 PDF download via HTTPS seems broken

I've been going nuts about PDF downloads to mobile devices. 我一直在疯狂地将PDF下载到移动设备上。 Here's the next madness, observable on Android 2.2 and 2.3. 这是下一个疯狂,可以在Android 2.2和2.3上观察到。 I couldn't reproduce this problem on iPhones or other devices, neither on Firefox or other desktop browsers. 我无法在iPhone或其他设备上重现此问题,也无法在Firefox或其他桌面浏览器上重现此问题。

I'm downloading a PDF via HTTP and it works just fine. 我正在通过HTTP下载PDF,它工作得很好。 Then I'm downloading the same PDF via HTTPS and the download doesn't finish (and the filename is lost): 然后我通过HTTPS下载相同的PDF并且下载没有完成(文件名丢失):

下载未完成,文件名丢失

I'm using these HTTP headers (and others, which are irrelevant here): 我正在使用这些HTTP标头(以及其他与此无关的标头):

Content-Disposition: attachment; filename="abc.pdf"
Content-Type: application/pdf

Changing the Content-Disposition to inline or removing it entirely doesn't help either. Content-Disposition更改为inline或完全删除也无济于事。 Removing the Content-Type will results in displaying the raw binary data in the browser window. 删除Content-Type将导致在浏览器窗口中显示原始二进制数据。

Note: I've already discovered a problem related to untrusted SSL certificates , but that doesn't seem to be the only problem. 注意:我已经发现了与不受信任的SSL证书相关的问题 ,但这似乎不是唯一的问题。 So I'm really looking for yet another explanation. 所以我真的在寻找另一种解释。

Any ideas welcome! 欢迎任何想法!

As always, after some hard looking there is an ancient bug report on google code with lots of frustrated developer comments... Here are two open issues related to this problem: 与往常一样,经过一番艰苦的研究后,谷歌代码上有一个古老的错误报告,其中有很多令人沮丧的开发者评论......以下是与此问题相关的两个未解决的问题:

It seems that downloading PDFs using SSL with untrusted certificates (which is the case in my test environment) doesn't work with exactly the symptoms that I have mentioned 似乎使用带有不受信任证书的SSL下载PDF(在我的测试环境中就是这种情况)并不能完全解决我提到的症状

Update : That is only one problem. 更新 :这只是一个问题。 But it doesn't seem to be the only one 但它似乎并不是唯一的一个

Update : As a matter of fact, here is some authoritative information on the whole matter, showing that at the time, Content-Disposition was poorly implemented and specified , which explains many problems encountered when implementing downloads over HTTP: 更新 :事实上,这里有一些关于整个问题的权威信息,表明当时Content-Disposition实现和指定很差,这解释了在通过HTTP实现下载时遇到的许多问题:

http://greenbytes.de/tech/tc2231 http://greenbytes.de/tech/tc2231

Besides the certificate validity, the order of the CA chain is also important for the Android download manager to be able to download files. 除了证书有效性之外,CA链的顺序对于Android下载管理器能够下载文件也很重要。

In order to make sure the intermediate certificates are in the proper order, you can run the following command: 为了确保中间证书的顺序正确,您可以运行以下命令:

openssl s_client -connect www.google.ch:443 -showcerts | grep ":/[C1]"

This should return a nicely ordered chain such as: 这应该返回一个很好的有序链,例如:

0) subject: server
   issuer:  ca1
1) subject: ca1
   issuer:  ca2
2) subject: ca2
   issuer:  ca3

And not something like this: 而不是这样的事情:

0) subject: server
   issuer:  ca1
1) subject: ca2
   issuer:  ca3
2) subject: ca1
   issuer:  ca2

Unable to test this right now as I don't have an https server running anywhere convenient, but does sending Content-Type: application/octet-stream with the headers make any difference? 由于我没有在任何方便的地方运行https服务器,但是现在无法对此进行测试,但发送带有标头的Content-Type: application/octet-stream会有什么不同吗?

Obviously, based on your situation and requirements, this may not be an option. 显然,根据您的情况和要求,这可能不是一种选择。 Beyond that, try with a valid SSL certificate! 除此之外,请尝试使用有效的SSL证书!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM