2016-08-09 65 views
1

當我在android API 17上測試NativeScript應用程序時遇到問題。 安裝正常,但是當我嘗試使用HTTP請求登錄到我的HTTPS後端時,請求立即停止。Nativescript應用程序不適用於Android API 17

這隻發生在API 17而不是更高的API上。

Error: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

http.request({ 
    url: config.baseUrl + "login", 
    method: "POST", 
    headers: {"Content-Type": "application/x-www-form-urlencoded"}, 
    content: "grant_type=password&username=" + this.username + "&password=" + this.password 
}); 
+0

如果它是https,你不應該請求https嗎? –

+2

可能重複[Trust Anchor Connection找不到Android SSL連接](http://stackoverflow.com/questions/6825226/trust-anchor-not-found-for-android-ssl-connection) –

+0

鏈接的最新評論上面:http://stackoverflow.com/a/16302527/4936697 –

回答

1

我有有效的同樣的問題(不是自籤)證書。事實證明,CA未安裝在Android模擬器(Nexus 6 - API 21)上。

我從我的瀏覽器中導出CA證書並將其導入到Emulator中。

爲了做到這一點,您需要啓用SDCard。然後複製證書(我通過「avd push」命令做到了這一點)。然後從設置 - >安全 - >從SD卡安裝導入。相同的步驟應該適用於自簽名證書。

相關問題