I wrote that code:
Server:
Qt Code:
  1. //H
  2.  
  3. #ifndef POLACZENIESSL_H
  4. #define POLACZENIESSL_H
  5. #include <QTcpServer>
  6. #include <QTcpSocket>
  7. #include <QSslSocket>
  8. #include <QFile>
  9. #include <QSslKey>
  10. #include <QAbstractSocket>
  11. class PolaczenieSSL : public QTcpServer
  12. {
  13. Q_OBJECT
  14. public:
  15. PolaczenieSSL(QWidget *parent = 0);
  16. ~PolaczenieSSL();
  17. private:
  18. void incomingConnection(int port);
  19. private slots:
  20. void gotowy();
  21. };
  22.  
  23. #endif // POLACZENIESSL_H
  24.  
  25. //CPP
  26.  
  27. #include "polaczeniessl.h"
  28.  
  29. PolaczenieSSL::PolaczenieSSL(QWidget *parent)
  30. {
  31.  
  32. }
  33. PolaczenieSSL::~PolaczenieSSL()
  34. {
  35.  
  36. }
  37. void PolaczenieSSL::incomingConnection(int port)
  38. {
  39. qDebug()<<"incomingConnection";
  40. QSslSocket *serverSocket = new QSslSocket;
  41. serverSocket->setProtocol(QSsl::AnyProtocol);
  42. serverSocket->ignoreSslErrors();
  43. QFile *file = new QFile("server.key");
  44. QSslKey key(file, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, "server");
  45. serverSocket->setPrivateKey(key);
  46. serverSocket->setLocalCertificate("server.csr");
  47. serverSocket->addCaCertificates("/etc/ssl/certs");
  48. if (serverSocket->setSocketDescriptor(port))
  49. {
  50. connect(serverSocket, SIGNAL(encrypted()), this, SLOT(gotowy()));
  51. serverSocket->startServerEncryption();
  52. qDebug()<<serverSocket->errorString();
  53.  
  54. }
  55. else
  56. {
  57. delete serverSocket;
  58. }
  59. }
  60.  
  61. void PolaczenieSSL::gotowy()
  62. {
  63. qDebug()<<"gotowy";
  64. }
To copy to clipboard, switch view to plain text mode 
On console, when client started connection:
Qt Code:
  1. incomingConnection
  2. "Unknown error"
To copy to clipboard, switch view to plain text mode 

What is it wrong?