Michel Foucault Michel Foucault - 15 days ago 6
jQuery Question

Phonegap Cordova file transfer with HTTPS protocol

I'm working with

Phonegap 6.3.3
. I have to download a file. If my endpoint is a
HTTP
connection the operation is ok, but if endpoint use a
HTTPS
(TLS 1.2) connection
fileTransfer.download
return
error.code = 3


getDocumentFile : function(docId, fileName,successClb,errorClb){
var url = this.endpoint + "/contents/getDocument?documentId=" + docId;
var filePath = cordova.file.externalDataDirectory + fileName;

var fileTransfer = new FileTransfer();
fileTransfer.download(
url,
filePath,
function(entry) {
successClb(entry.nativeURL);
},
function(error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
errorClb(error);
},
false
);


Usign ajax call with Jquery with
HTTPS
protocol I have not any problem.
Can you help me please?

Answer

I've found the solution. The correct call for HTTPS with certificate auto signed (not trusted) is following. It is important passing true to penultimate parameter (allowAllHost). For more information you read the reference cordova

new FileTransfer();
        fileTransfer.download(
                    url,
                    filePath,
                    success,
                    error,
                    true
                );