actionscript-3 - AS3:协商 FTP-ES 连接
问题描述
我正在尝试修改 ActionScript 3 FTP 库以支持显式安全 (FTP-ES) 连接。
使用 FTP-ES,客户端最初建立一个不安全的 FTP 连接,然后明确要求服务器切换到安全的 SSL/TLS 连接。
现在,我最初使用常规 Socket 连接到 FTP 服务器,要求服务器切换到 TLS,然后在服务器返回 FTP 代码 234 后尝试使用 SecureSocket 连接:
if (code.indexOf('220 ') == 0 || code.indexOf('220-') == 0) { //Send user name
if (_useTLS) {
trace("AUTH TLS");
cmdSocket.writeUTFBytes('AUTH TLS\r\n');
} else {
cmdSocket.writeUTFBytes('USER ' + _username + '\r\n');
}
cmdSocket.flush();
}
if (responseCode.indexOf('234 ') == 0) { //Auth OK, expecting SSL/TLS negotatiation
if (SecureSocket.isSupported) {
secureCommandSocket = new SecureSocket();
secureCommandSocket.addEventListener(ProgressEvent.SOCKET_DATA, onReceivedSCmd);
secureCommandSocket.addEventListener(Event.CONNECT, onConnectSCmd);
secureCommandSocket.addEventListener(IOErrorEvent.IO_ERROR, onSocketError);
secureCommandSocket.addEventListener(Event.CLOSE, onCloseSCmd);
secureCommandSocket.connect(_host, _port);
} else {
throw new Error("Secure socket is not supported on this platform");
}
}
但是,套接字返回 IOError 2031(套接字错误)。这是输出:
MESSAGE: CONNECTED TO FTP
MESSAGE: Received command: 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
AUTH TLS
MESSAGE: Received command: 234 AUTH TLS OK.
MESSAGE: 2031:Error #2031: Socket Error. URL: xx.xx.xxx.xx
ERROR: Connection failed
由于没有更多关于出了什么问题的信息,我不知道为什么安全套接字连接失败了。是因为我试图从常规 Socket 切换到 SecureSocket 中间连接吗?如果是这样,在 AS3 中有没有其他方法可以处理这个问题?
解决方案
推荐阅读
- javascript - 处理来自后端的反应数据的最佳方法
- android - 如何将默认工具栏标题文本从@string/app_name 更改为“”,但只更改styles.xml?
- javascript - 错误:无法读取未定义的属性“状态”,努力让前端工作
- python - Errno 13 权限被拒绝 Keras VGG16
- python - 如何在 Seaborn 中绘制几列?
- javascript - 如果通过 UWP JavaScript 按下多个游戏手柄按钮
- ruby-on-rails - 不同 ResourceController 的共享资源
- sql-server - 如何在 Azure Synapse 专用池中监视较旧的查询历史记录和查询计划
- linux - 如何在bash中重命名多个文件?
- google-apps-script - 如何将 Apps 脚本项目恢复为 GCP 默认项目