AS3:协商FTP-ES连接

时间:2018-10-31 23:17:06

标签: actionscript-3 ftp ftpes

我正在尝试修改ActionScript 3 FTP库以支持显式安全(FTP-ES)连接。

使用FTP-ES,客户端最初会建立不安全的FTP连接,然后明确要求服务器切换到安全的SSL / TLS连接。

现在,我最初使用常规套接字连接到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

由于没有更多有关发生问题的信息,我不知道为什么安全套接字连接会失败。是因为我要从常规套接字切换到SecureSocket中间连接吗?如果是这样,在AS3中还有其他方法可以处理吗?

0 个答案:

没有答案