【发布时间】:2020-05-06 02:43:54
【问题描述】:
根据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();
}
}
}
我知道AUTH 命令与ftp_ssl_connect 的显式FTP/SSL 连接一起使用,我很困惑,我想知道这个命令对常规FTP 连接是否无用?
提前致谢!
【问题讨论】: