开发者

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开发者_如何学C 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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜