0

I get this exception "android javax.net.ssl.SSLException: 502 AUTH TLS OK" on HUAWEI P8 smartphone but it works well on SAMSUNG Galaxy J3 smartphone

import org.apache.commons.net.ftp.FTPSClient;

FTPSClient mFTPClient = new FTPSClient("TLS", false);

mFTPClient.connect(sFTPServer,iFTPPort) => exception android javax.net.ssl.SSLException: 502 AUTH TLS OK

HUAWEI P8 versionHUAWEI P8 version

Samsung Galaxy J3 versionSamsung Galaxy J3 Version

This command works with the SAMSUNG GALAXY J3 smartphone but does not work with the HUAWEI P8 smartphone: how can I solve it?


PhilippeC
  • 13
  • 2
  • Can you find Android versions of both devices? This will help you to see, what is the difference between two environments. – samu Jan 16 '20 at 14:07
  • A [similar problem](https://stackoverflow.com/questions/50868600/https-client-with-ftp-login-error-javax-net-ssl-sslexception-502-sslv23-tlsv1) seems to have been solved using `ftps.mydomain.com` instead of `ftp.mydomain.com`. – Agnohendrix Jan 18 '20 at 18:43

1 Answers1

0

According to this security rules have changed in Android 9(API 28+), so you should use a way to permit clear traffic to connect to your server.

A simple way should be adding:

android:usesCleartextTraffic="true"

to your <application> tag in Manifest

You could try this way too: Add:

android:networkSecurityConfig="@xml/network_security_config"

to your <application> tag in the app manifest and then create the XML file "network_security_config.xml" :

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
</network-security-config>

You find references here and a similar question here

Agnohendrix
  • 480
  • 1
  • 7
  • 17
  • Do you know where to create in android studio the XML file "network_security_config.xml" ? In which directory ? – PhilippeC Jan 30 '20 at 23:00
  • I put it under "res/xml/", so its path will be res/xml/network_security_config.xml", then you can access to it in your manifest using "@xml/network_security_config" – Agnohendrix Jan 31 '20 at 10:31