agiuliani
agiuliani

Reputation: 21

Problem downloading file from FTP using QNetworkAccessManager::get() function

This is my first request.. :)

I am having some problem using the QT framework and downloading a single file (12kb long) from a FTP server. Some info regarding the problem:

What I experience is that I have no error message from QNetworkAccessManager, nor from QNetworkRequest object. Simply no anser, no error. Capturing QmetaObjectChange signal, I see only the code 200 from the server and the size of the file. Stop.

Any Ideas that can help me to find the reason why I experiment this strange behaviour? Thanks for your help.

Alberto.

Upvotes: 0

Views: 425

Answers (1)

agiuliani
agiuliani

Reputation: 21


I finally understood the problem.
Openssl library has intentionally disabled the use of obsolete and dangerous protocols like sslv2.That's why QT cannot download the file from that particular ftp server: the server uses sslv2.
Using obsolete protocols like sslv2 introduce the possibility that hackers can obtain sensible data intercepting your network session.
I think the best solution is to avoid my software to connect to such kind of ftp servers, I do not want to allow security problem also on my system.I will prompt an error message like : "error: the ftp server use an osolete and dangerous protocol(sslv2). Connection not allowed."
You can connect a slot to signal in order to get ssl warnings..

void DownloadManager::doDownload(const QUrl &url)
{
    QNetworkRequest request(url);
    QNetworkReply *reply = manager.get(request);

#if QT_CONFIG(ssl)
    connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
            SLOT(sslErrors(QList<QSslError>)));
#endif

    currentDownloads.append(reply);
}

https://code.qt.io/cgit/qt/qtbase.git/tree/examples/network/download/main.cpp?h=5.14

BR! : )

Upvotes: 1

Related Questions