阻止Apache Commons VFS尝试使用SSL

时间:2014-02-17 15:18:36

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

我正在尝试使用Apache Commons VFS从http://openexchangerates.org API获取数据。我收到的错误暗示它正在尝试使用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

1 个答案:

答案 0 :(得分:1)

网站会将重定向发送到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