Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FTPS (FTP-SSL) in Qt 4.6

Tags:

ssl

openssl

qt

ftp

qt4

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:

  • FTP over SSL/TLS support enabled
  • Explicit FTP over TLS enabled
  • Plain unencrypted FTP disallowed
  • SSL forced for roots login

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!

like image 950
atamanroman Avatar asked Oct 13 '22 19:10

atamanroman


1 Answers

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.

like image 135
Piotr Dobrogost Avatar answered Oct 18 '22 02:10

Piotr Dobrogost