"android javax.net.ssl.SSLException: 502 AUTH TLS OK" 在 HUAWEI 智能手机上,但它在 SAMSUNG 智能手机上运行良好。为什么?

"android javax.net.ssl.SSLException: 502 AUTH TLS OK" on HUAWEI smartphone but it works well on a SAMSUNG smartphone. Why?

我在 HUAWEI P8 智能手机上遇到此异常 "android javax.net.ssl.SSLException: 502 AUTH TLS OK" 但它在 SAMSUNG Galaxy J3 智能手机上运行良好

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

华为P8版

三星 Galaxy J3 版

此命令适用于 SAMSUNG GALAXY J3 智能手机,但不适用于 HUAWEI P8 智能手机:如何解决?


根据 this 安全规则在 Android 9(API 28+) 中发生了变化,因此您应该使用一种允许清晰流量连接到您的服务器的方法。

一个简单的方法应该是添加:

android:usesCleartextTraffic="true"

您在清单中的 <application> 标签

你也可以这样试试: 添加:

android:networkSecurityConfig="@xml/network_security_config"

添加到应用程序清单中的 <application> 标记,然后创建 XML 文件 "network_security_config.xml" :

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

您找到参考资料 here and a similar question