2014-02-17 80 views
0

我試圖使用Apache Commons VFS從http://openexchangerates.org API獲取數據。我收到的錯誤意味着它試圖使用SSL驗證 - 而不是我通過我的網站計劃提供的東西。有沒有辦法可以'強制'VFS使用http而不是https?阻止Apache Commons VFS嘗試使用SSL

巨大的堆棧跟蹤的相關要點如下包括 - 如果需要,可以提供更多的信息:

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

網站發送重定向到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 
+0

感謝您的解釋! – Serenthia

相關問題