fix: CCC Command RFC

This commit is contained in:
Ugo
2025-07-19 09:29:59 +01:00
parent 646404da3a
commit f65d8d20f6

View File

@ -447,20 +447,29 @@ int parseCommandCcc(ftpDataType *data, int socketId)
int returnCode; int returnCode;
#ifdef OPENSSL_ENABLED #ifdef OPENSSL_ENABLED
if (!data->clients[socketId].tlsIsEnabled) {
returnCode = socketPrintf(data, socketId, "s", "533 Control connection not encrypted\r\n");
if (returnCode <= 0) {
LOG_ERROR("socketPrintfError");
return FTP_COMMAND_PROCESSED_WRITE_ERROR;
}
return FTP_COMMAND_PROCESSED;
}
returnCode = socketPrintf(data, socketId, "s", "200 TLS connection aborted\r\n"); returnCode = socketPrintf(data, socketId, "s", "200 Control connection switched to plaintext\r\n");
SSL_set_shutdown(data->clients[socketId].ssl, SSL_SENT_SHUTDOWN);
data->clients[socketId].tlsIsEnabled = 0;
if (returnCode <= 0) if (returnCode <= 0)
{ {
LOG_ERROR("socketPrintfError"); LOG_ERROR("socketPrintfError");
return FTP_COMMAND_PROCESSED_WRITE_ERROR; return FTP_COMMAND_PROCESSED_WRITE_ERROR;
} }
SSL_shutdown(data->clients[socketId].ssl); // Clean shutdown
data->clients[socketId].tlsIsEnabled = 0; // Mark as plaintext
#endif #endif
#ifndef OPENSSL_ENABLED #ifndef OPENSSL_ENABLED
returnCode = socketPrintf(data, socketId, "s", "502 command not supported\r\n"); returnCode = socketPrintf(data, socketId, "s", "502 Command not supported\r\n");
if (returnCode <= 0) if (returnCode <= 0)
{ {