atamanroman
atamanroman

Reputation: 11808

FTPS (FTP-SSL) in Qt 4.6

Im trying to get FTP-SSL to work with Qt 4.6.3. I've already compiled Qt with OpenSSL support. Are there any good resources about FTPS with Qt? It seems that QFtp does not provide SSL support. I really dont want to create my own FTPS implementation.

// edit: I discovered QNetworkAccessManager (ty @ frank) but I cant find any useful documentation or examples for SSL with it. Thats what I'm trying:

QUrl url = QUrl("ftp://localhost/filex.txt");
url.setUserName("root");
url.setPassword("root");
QNetworkRequest request(url);
QSslConfiguration SslConfiguration(QSslConfiguration::defaultConfiguration());
request.setSslConfiguration(SslConfiguration);
manager->get(request);

But FileZilla wont let me connect. The FZ console says:

(000035)21.12.2010 17:31:46 - (not logged in) (127.0.0.1)> USER root

(000035)21.12.2010 17:31:46 - (not logged in) (127.0.0.1)> 530 SSL required

FileZilla configuration:

I would at least expect some sort of sslErrors signals since user/pw is fine and SSL fails, but I'm only getting authenticationRequired signals.

Thanks for your help!

Upvotes: 5

Views: 3542

Answers (1)

Piotr Dobrogost
Piotr Dobrogost

Reputation: 42425

Unfortunately there's no out of the box solution for FTPS in Qt.

  • QFtp implements many ftp commands but does not support encryption.
  • QNetworkAccessManager supports only basic ftp functions (file download/upload) and does not support encryption in case of ftp, either. It's worth to mention it does support encryption for HTTP, which is the protocol it's mainly designed for.
  • QSslSocket implements SSL but no specific protocol like FTP or HTTP

Taking above information into consideration an idea comes to mind to mix QFtp with QSslSocket to get encrypted FTP. The problem is QFtp class has no method which would allow to make QFtp use user supplied socket. By comparision QHttp has such a method - int QHttp::setSocket(QTcpSocket * socket)

Bottom line; according to Thiago Macieira (designer of QNetworkAccessManager) the way to go is to implement FTP protocol using QSslSocket.

Upvotes: 4

Related Questions