具有ftp_connect功能的AUTH TLS / SSL

问题描述 投票:0回答:1

根据RFC 2228,AUTH是FTP命令,可以与一种身份验证机制(TLS或SSL)一起使用,以保护数据通道和控制通道。

我想知道我是否可以通过具有ftp_connect功能的非安全连接(常规FTP)使用此命令,如下所示:

$conn = ftp_connect('hostname');

if (is_ressoure($conn)) {
    $command = ftp_raw($conn, 'AUTH TLS');
    $responseCode = (int) substr($command[0], 0, 3);

    if ($responseCode === 234) {
        // AUTH TLS success
        login(); // secured

    } else { // if TLS rejected try SSL

        $command = ftp_raw($conn, 'AUTH SSL');
        $responseCode = (int) substr($command[0], 0, 3);

        if ($responseCode === 234) {
            // SSL authentication success
            login(); // secured

        } else {
            // Cannot secure the data channel and command channel
            die();
        }
    }
}

我知道与ftp_ssl_connect的显式FTP / SSL连接一起使用的AUTH命令,我很困惑,我想知道该命令对常规FTP连接是否无用?

提前感谢!

php ssl ftp explicit
1个回答
0
投票

AUTH TLS/SSL将连接加密。如果将其与普通ftp_connect连接一起使用,则该连接将停止工作。服务器将期待加密的命令(并发送加密的响应),而客户端(PHP FTP模块)将继续发送意外的命令(并期待未加密的响应)。他们不会互相了解。实际上,它甚至都无法达到目标,因为在AUTH之后,服务器将启动TLS握手,并且将立即失败。

© www.soinside.com 2019 - 2024. All rights reserved.