我正在使用$cordovaFileTransfer
(围绕cordova-plugin-file-transfer 1.7.1 "File Transfer"
& cordova-plugin-file 6.0.1 "File"
的ngCordova包装器)。
此代码在iOS(11.x)上运行正常,但已停止在Android 7.0上工作(正在使用6.x)
错误是:
May 3, 2018 03:26:47 PM INFO Error
{"code":3,"source":"https://server/zm/index.php?
view=view_video&eid=218648","target":
"file:///data/user/0/com.pliablepixels.zmninja_pro/files/temp-video.mp4","http_status":null,"body":null,
"exception":"java.security.cert.CertPathValidatorException:
Trust anchor for certification path not found."}
有问题的代码:
$cordovaFileTransfer.download(path, tp, opt, th)
其中:
path: url to mp4 file
tp: target path on device
opt = {}
th = true (I used self signed certificates)
鉴于此代码在Android 6中运行良好,您是否知道我需要考虑对7的任何更改?
详细的adb日志,如果有帮助:
05-03 15:26:47.156 5410 5410 D SystemWebChromeClient: file:///android_asset/www/lib/filelogger/dist/filelogger.min.js: Line 6 : May 3, 2018 03:26:47 PM DEBUG Saving temporary video to: file:///data/user/0/com.pliablepixels.zmninja_pro/files/temp-video.mp4
05-03 15:26:47.156 5410 5410 I chromium: [INFO:CONSOLE(6)] "May 3, 2018 03:26:47 PM DEBUG Saving temporary video to: file:///data/user/0/com.pliablepixels.zmninja_pro/files/temp-video.mp4", source: file:///android_asset/www/lib/filelogger/dist/filelogger.min.js (6)
05-03 15:26:47.160 5410 5644 D FileTransfer: download https://myserver/zm/index.php?view=view_video&eid=218648 to file:///data/user/0/com.pliablepixels.zmninja_pro/files/temp-video.mp4
05-03 15:26:47.161 5410 13546 D FileTransfer: Download file:https://myserver/zm/index.php?view=view_video&eid=218648
05-03 15:26:47.270 5410 13548 D TEST : cdvfile://localhost/files/zmNinjaLog.txt: 128
05-03 15:26:47.308 5410 13546 W FileTransfer: Error getting HTTP status code from connection.
05-03 15:26:47.308 5410 13546 W FileTransfer: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:361)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.okhttp.Connection.connectTls(Connection.java:235)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.okhttp.Connection.connectSocket(Connection.java:199)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.okhttp.Connection.connect(Connection.java:172)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:329)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java)
05-03 15:26:47.308 5410 13546 W FileTransfer: at org.apache.cordova.filetransfer.FileTransfer$2.run(FileTransfer.java:779)
05-03 15:26:47.308 5410 13546 W FileTransfer: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
05-03 15:26:47.308 5410 13546 W FileTransfer: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
05-03 15:26:47.308 5410 13546 W FileTransfer: at java.lang.Thread.run(Thread.java:761)
05-03 15:26:47.308 5410 13546 W FileTransfer: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.org.conscrypt.TrustManagerImpl.verifyChain(TrustManagerImpl.java:563)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:444)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:401)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:375)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:304)
05-03 15:26:47.308 5410 13546 W FileTransfer: at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94)
05-03 15:26:47.308 5410 13546 W FileTransfer: at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:178)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:596)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
05-03 15:26:47.308 5410 13546 W FileTransfer: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
05-03 15:26:47.308 5410 13546 W FileTransfer: ... 15 more
05-03 15:26:47.308 5410 13546 W FileTransfer: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
05-03 15:26:47.308 5410 13546 W FileTransfer: ... 26 more
05-03 15:26:47.309 5410 13546 E FileTransfer: {"code":3,"source":"https:\/\/myserver\/zm\/index.php?view=view_video&eid=218648","target":"file:\/\/\/data\/user\/0\/com.pliablepixels.zmninja_pro\/files\/temp-video.mp4","http_status":0,"exception":"java.security.cert.CertPathValidatorException: Trust anchor for certification path not found."}
05-03 15:26:47.309 5410 13546 E FileTransfer: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:361)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.okhttp.Connection.connectTls(Connection.java:235)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.okhttp.Connection.connectSocket(Connection.java:199)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.okhttp.Connection.connect(Connection.java:172)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:329)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java)
05-03 15:26:47.309 5410 13546 E FileTransfer: at org.apache.cordova.filetransfer.FileTransfer$2.run(FileTransfer.java:779)
05-03 15:26:47.309 5410 13546 E FileTransfer: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
05-03 15:26:47.309 5410 13546 E FileTransfer: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
05-03 15:26:47.309 5410 13546 E FileTransfer: at java.lang.Thread.run(Thread.java:761)
05-03 15:26:47.309 5410 13546 E FileTransfer: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.org.conscrypt.TrustManagerImpl.verifyChain(TrustManagerImpl.java:563)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:444)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:401)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:375)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:304)
05-03 15:26:47.309 5410 13546 E FileTransfer: at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94)
05-03 15:26:47.309 5410 13546 E FileTransfer: at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:178)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:596)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
05-03 15:26:47.309 5410 13546 E FileTransfer: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
05-03 15:26:47.309 5410 13546 E FileTransfer: ... 15 more
05-03 15:26:47.309 5410 13546 E FileTransfer: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
05-03 15:26:47.309 5410 13546 E FileTransfer: ... 26 more
由于
答案 0 :(得分:0)
问题解决了。有必要在设备上安装自签名证书。我不记得以前是否在Android 6上安装过它,所以不是百分之百确定它是否只是Android 7的问题。