gpt4 book ai didi

Android 浏览器不从 HTTPS 自签名认证下载文件

转载 作者:行者123 更新时间:2023-11-30 03:02:14 26 4
gpt4 key购买 nike

我们有一个经过认证的自签名 tomcat webapp。当用户单击帮助按钮然后下载 pdf 文件时,在 pc 浏览器中它可以工作,但在 android 中它会在不确定的时间继续下载。

我在 Spring Controller 中使用这段代码:

URL url = servletContext.getResource("/manual/Manual.pdf");

response.setHeader("Content-Disposition", "attachment; filename=\"Manual.pdf\"");
response.setContentType("application/octect-stream");
response.setContentLength(url.getFile().length());


try
{
InputStream fis = url.openStream();
OutputStream out = response.getOutputStream();
IOUtils.copy(fis, out);
out.flush();

}catch(IOException ioe)
{
logger.error(ioe);
}

我们正在使用 https 和端口 9443。

我在 android 的 logcat 中遇到了这个错误:

Application: android.process.media
Tag: DownloadManager
Text: Aborting request for download 23:
while trying to execute request: javax.net.ssl.SSLHandshakeException:
java.security.cert.CertPathValidatorException:
Trust anchor for certification path not found.

感谢您的帮助。

最佳答案

事实证明,证书是自动生成的,因此出现了问题。我们使用 HTTP 而不是 HTTPS 来下载,这很有效 :D

关于Android 浏览器不从 HTTPS 自签名认证下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22355497/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com