我们的应用程序中有图像上传功能。当我们使用HTTP时,此功能可以正常工作,但当启用SSL时会失败。在网上冲浪后,我得到了一些代码,即在上传方法中添加真实属性
ft.upload(fileuri, encodeURI(PublishUrl+"FileUpload"), win, fail, options,true);
但不起作用
错误日志
07-11 19:44:40.651: E/FileTransfer(17526): {"target":"Url","source":"file:///storage/emulated/0/PopImg/cache/Car/Crazy_Racer/sm_1_(10).jpg","http_status":0,"code":3}
07-11 19:44:40.651: E/FileTransfer(17526): java.net.SocketException: Socket is closed
07-11 19:44:40.651: E/FileTransfer(17526): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.checkOpen(OpenSSLSocketImpl.java:232)
07-11 19:44:40.651: E/FileTransfer(17526): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:245)
07-11 19:44:40.651: E/FileTransfer(17526): at libcore.net.http.HttpConnection.setupSecureSocket(HttpConnection.java:209)
07-11 19:44:40.651: E/FileTransfer(17526): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:478)
07-11 19:44:40.651: E/FileTransfer(17526): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:442)
07-11 19:44:40.651: E/FileTransfer(17526): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)
07-11 19:44:40.651: E/FileTransfer(17526): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)
07-11 19:44:40.651: E/FileTransfer(17526): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)
07-11 19:44:40.651: E/FileTransfer(17526): at libcore.net.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:165)
07-11 19:44:40.651: E/FileTransfer(17526): at org.apache.cordova.FileTransfer$1.run(FileTransfer.java:344)
07-11 19:44:40.651: E/FileTransfer(17526): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-11 19:44:40.651: E/FileTransfer(17526): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-11 19:44:40.651: E/FileTransfer(17526): at java.lang.Thread.run(Thread.java:856)
07-11 19:44:40.651: E/FileTransfer(17526): Failed after uploading 0 of 18171 bytes.
有什么建议吗?
出于测试目的,我的移动流量是通过Fiddler路由的。Android设备可能无法使用Fiddler使用的默认HTTPS拦截证书。通过禁用小提琴,它起了作用。