apache - 阻止 Apache Commons VFS 尝试使用 SSL

标签 apache ssl apache-commons-vfs currency-exchange-rates

我正在尝试从 http://openexchangerates.org 获取数据API 使用 Apache Commons VFS。我收到的错误暗示它正在尝试使用 SSL 验证——这不是我通过我的网站计划提供的东西。有没有一种方法可以“强制”VFS 使用 http 而不是 https?

巨大堆栈跟踪的相关点包含在下面 - 如果需要,可以提供更多信息:

org.apache.commons.vfs2.VFS.getManager().resolveFile("http://openexchangerates.org/api/latest.json?api_id=MY_APP_ID")
org.apache.commons.vfs2.FileSystemException: Could not connect to HTTP server on "openexchangerates.org".

Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

最佳答案

该网站发送重定向到 https 版本。因此它不支持http。 http 客户端将自动遵循此重定向,您需要对其进行配置以进行正确验证。

这是我如何检查的:

$ curl -v http://openexchangerates.org/api/latest.json?api_id=MY_APP_ID
* Connected to openexchangerates.org (185.24.96.251) port 80 (#0)
> GET /api/latest.json?api_id=MY_APP_ID HTTP/1.1
> User-Agent: curl/7.30.0
> Host: openexchangerates.org
> Accept: */*

< HTTP/1.1 301 Moved Permanently
< Date: Mon, 05 Jan 2015 23:37:18 GMT
< Server: Apache
< Location: https://openexchangerates.org?missing_app_id=true

关于apache - 阻止 Apache Commons VFS 尝试使用 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21832757/

相关文章:

apache - .htaccess 重定向/重写问题

php 在内容前插入十六进制字符数

本地主机上的 SSL 证书无效

vb.net - 重定向到 SSL/HTTPS

java - Windows机器上无法通过VFS下载文件?

java - Apache VFS sftp-正在获取多个文件对象来创建多个 session 或 channel ?

linux - 为什么即使以 root 用户身份运行成功,ant build 也会因 sudo 而失败?

apache - Apache-无效的命令 'SSLMutex'

javascript - 无法使用 express Node 设置 ssl

java - 使用 Apache Commons VFS 通过 FTP URI 导航到根目录