Hi, I don't know why the encrypted signal is not emitted in this code:

Qt Code:
  1. SSLServer::SSLServer(int socket_descriptor, QObject *parent) : QObject(parent) {
  2. /* create server socket */
  3. server = new QSslSocket(this);
  4.  
  5. /* call a slot after 1 second - to terminate the unauthenticated connection */
  6. QTimer::singleShot(1000, this, SLOT(abort_connection()));
  7.  
  8. /* set socket descriptor */
  9. if(!server->setSocketDescriptor(socket_descriptor)) {
  10. qWarning("Failed to set socket descriptor in SSLServer");
  11. close(socket_descriptor);
  12. delete this;
  13. return;
  14. }
  15.  
  16. /* add CA certificate: it is used by the handshake process to validate the peer's certificate*/
  17. QSslCertificate ca_cert = handle_certificate(":/central_authority.crt");
  18. server->addCaCertificate(ca_cert);
  19.  
  20. /* set the server's (LOCAL) digital certificate */
  21. QSslCertificate server_cert = handle_certificate(":/server.crt");
  22. server->setLocalCertificate(server_cert);
  23.  
  24. /* set the server's (LOCAL) private key -> [key+certificate == prove identity to SSL peer] */
  25. server->setPrivateKey(":/server.key", QSsl::Rsa, QSsl::Pem, "");
  26.  
  27. /* set cipher protocol */
  28. server->setProtocol(QSsl::SslV3);
  29.  
  30. /* server has to ask the client to send the certificate */
  31. /* the client ask the server to send the certificate by default */
  32. server->setPeerVerifyMode(QSslSocket::VerifyPeer);
  33.  
  34. /* starts a delayed SSL handshake */
  35. server->startServerEncryption();
  36.  
  37. #ifdef SSL_DEBUG
  38. /* wait for socket to complete SSL handshake -> when encrypted it emits encrypted signal */
  39. if(server->waitForEncrypted(1000))
  40. print_socket_info();
  41. #endif
  42.  
  43. connection_established();
  44.  
  45. /* if handshake is successful and encrypted socket is ready to use */
  46. connect(server, SIGNAL(encrypted()), this, SLOT(connection_established()));
  47. /* if error occurs the sslErrors() signal is emitted */
  48. connect(server, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(error_occured(const QList<QSslError> &)));
  49. }
  50.  
  51. void SSLServer::connection_established() {
  52. qDebug() << "SSL Handshake succedded. The socket is now encrypted." << endl;
  53. get_certificate_data();
  54. create_files_dir();
  55. }
To copy to clipboard, switch view to plain text mode 

This is the server...on the client the encrypted() signal is emitted without a problem.

Any ideas...I need functionality to know when a socket is encryted, so I can start sending files to the client...thanks