Image upload with FileUpload fails when transferred over verified SSL ... but only on some android devices...

  • 1
  • Problem
  • Updated 4 years ago
OK, so... uploading photos from the app was never a problem... UNTIL SSL was installed on the domain where I transfer the photos to...

When I upload to a domain without SSL (http:// URL), I have no problems at all from any OS and device.

When I upload to a domain through SSL (an https:// domain):
- I have no problems with iOS iphone 4
- I have no problems with Android Sony XPeria phone
BUT
- I HAVE PROBLEMS with Android Samsung Galaxy Tab 3 tablet

Error code 3 is returned by the plugin in the errorCallback function (Code = 3).

After extensive searches on the web I have played with these 3 parameters that have helped other people. However they made no difference to me:
(1) I've set a header with Connection=close to the FileUploadOptions
var uploadOptions = new FileUploadOptions();

uploadOptions.headers = {
Connection: "close"
};


(2) I've turned off chunkedMode by setting it to false
uploadOptions.chunckedMode=false;

(3) I've added a sixt parameter to the upload function with value true

ft.upload(
file_url,
encodeURI('https://myurl.com/add_temporary_media.php'),
successCallback,
errorCallback,
uploadOptions,
true);


The ONLY way FileUpload worked was when I changed the URL to http:// instead of https://

Here is a code extract:


if (FileTransfer && FileUploadOptions)
{
log("FileTransfer and FileUploadOptions objects exist");
var uploadOptions = new FileUploadOptions();
uploadOptions.httpMethod="POST";
uploadOptions.mimeType="image/jpeg";
uploadOptions.params=form_data;
uploadOptions.chunkedMode=false;
uploadOptions.headers = {
Connection: "close"
};

log(JSON.stringify(uploadOptions));

var ft = new FileTransfer();
ft.onprogress = onProgressCallBack;

ft.upload(
file_url,
encodeURI(FH.Settings.WebServicesBaseURL() + 'add_temporary_media.php'),
successCallback,
errorCallback,
uploadOptions,
true);

log("upload method called");
}


The strange part is that it works on one android device and not on the other...

Any help is very much appreciated.
Photo of Aaron Gusman

Aaron Gusman

  • 47 Posts
  • 0 Reply Likes
  • sad

Posted 4 years ago

  • 1
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Have you checked the other returned values (as for source, target, http return code, response body and error message)? They might show additional useful information.
Photo of Aaron Gusman

Aaron Gusman

  • 47 Posts
  • 0 Reply Likes
e.source and e.target are OK, e.https_status and e.body are null, but then I have e.exception reading as follows:

SSL handshake aborted: SSL=0x57c45220: I/O error during system call, Connection reset by peer

...
Photo of Aaron Gusman

Aaron Gusman

  • 47 Posts
  • 0 Reply Likes
Someone over here seems to have recently experienced my same problem, but I don't understand his solution:

http://stackoverflow.com/questions/28...
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Googling this message returns many possible causes. They all boil down to "there is something where client and server are incompatible". I found forum entries claiming:
- the client only does "TLS 1.0" and the server doesn't support that
- the client uses a DNS which doesn't identify the server correctly
- the client can connect to server only through WLAN, not through a mobile connections

In your case, you might want to
- try different situations with the Tab3, for instance see if the connection type makes any difference
- see what your server's log files say. They might reject some secure protocol initiated by the client.
- google for your error message (of course wthout the specific SSL= value) to see if there are other suggested causes that might ring a bell.

Sorry for not being able to be more specific.
Photo of jcesarmobile

jcesarmobile

  • 283 Posts
  • 40 Reply Likes
Which android version does the galaxy tab has?
Can you provide more information about the certificate you installed?

Not all certificates are trusted by all the android versions (same with iOS), that's probably your problem, but it's strange, because your last param is for trusting all certificates and you set it to true.
Photo of jcesarmobile

jcesarmobile

  • 283 Posts
  • 40 Reply Likes
Well, the iOS 9 problem can be solved configuring the ATS to allow TLS 1.0.
But as you say, it's really strange if ajax works and FileUpload doesn't
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
What confuses me is that fact that jQuery ajax web services over the https URLs are working fine form me from android 4.4.4
That's indeed strange. One would expect ajax requests using tls1.2 to fail as well. Unless the whitelist plugin intercepts such request and 'under the hood' performs the request to http://... instead (or it enables TLS v1.2; all over the place there are Java Socket examples available on how to do that)

It is only the FileUpload plugin that is failing on me.
I am confused now. Until now, I thought you used the FileTransfer plugin.
If you are, which version of the plugin are you using?
Photo of Aaron Gusman

Aaron Gusman

  • 47 Posts
  • 0 Reply Likes
I meant FileTransfer not FileUpload as the code snippet itself reveals...
Photo of jcesarmobile

jcesarmobile

  • 283 Posts
  • 40 Reply Likes
The issue you link is about the browser, and FileTransfer plugin uses a native connection, so it shouldn't be related. I have an app that connects to TLS 1.2 just fine using a native connection, tested on a 4.1.1 device.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
OK. The latest version is 1.5.0 of Jan,16,2016.

Here's someone answering his own question to the issue:
http://stackoverflow.com/questions/28...
The answer is not confirmed or rejected.
Photo of mccraigmccraig

mccraigmccraig

  • 1 Post
  • 0 Reply Likes
i'm seeing this same issue - an ssl cert which worked fine with an earlier version of cordova-file-transfer is being rejected on android devices. the cert works fine for other api requsts, it's just the cordova-file-transfer request which is problematic

i filed a bug, so if anyone wants to vote for secure file transfer head this way -

https://issues.apache.org/jira/browse...#