Qt Code:
  1. #include "polaczeniessl.h"
  2.  
  3. PolaczenieSSL::PolaczenieSSL(QWidget *parent)
  4. {
  5.  
  6. }
  7. PolaczenieSSL::~PolaczenieSSL()
  8. {
  9.  
  10. }
  11. void PolaczenieSSL::incomingConnection(int port)
  12. {
  13. qDebug()<<"incomingConnection";
  14. QSslSocket *serverSocket = new QSslSocket;
  15. connect(serverSocket, SIGNAL(encrypted()), this, SLOT(gotowy()));
  16. connect(serverSocket,SIGNAL(stateChanged(QAbstractSocket::SocketState)),SLOT(stany(QAbstractSocket::SocketState)));
  17. connect(serverSocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(bledy(QAbstractSocket::SocketError)));
  18. connect(serverSocket,SIGNAL(sslErrors(QList<QSslError>)),this,SLOT(bledySSL(QList<QSslError>)));
  19. serverSocket->setProtocol(QSsl::AnyProtocol);
  20. //serverSocket->ignoreSslErrors();
  21. QFile *file = new QFile("server.key");
  22. QSslKey key(file, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, "server");
  23. serverSocket->setPrivateKey(key);
  24. serverSocket->setLocalCertificate("server.csr");
  25. serverSocket->addCaCertificates("/etc/ssl/certs");
  26. if (serverSocket->setSocketDescriptor(port))
  27. {
  28. serverSocket->startServerEncryption();
  29. }
  30. else
  31. {
  32. delete serverSocket;
  33. }
  34. }
  35.  
  36. void PolaczenieSSL::gotowy()
  37. {
  38. qDebug()<<"gotowy";
  39. }
  40. void PolaczenieSSL::stany(QAbstractSocket::SocketState state)
  41. {
  42. qDebug()<<"Stan: "<<state;
  43. }
  44. void PolaczenieSSL::bledy(QAbstractSocket::SocketError err)
  45. {
  46. qDebug()<<"Blad: "<<err;
  47. }
  48. void PolaczenieSSL::bledySSL(QList<QSslError> l)
  49. {
  50. for(int i=0;i<l.size();++i)
  51. qDebug()<<"BladSSL: "<<l.at(i);
  52. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. incomingConnection
  2. Stan: QAbstractSocket::ConnectedState
  3. Blad: QAbstractSocket::SocketError( 13 ) // The SSL/TLS handshake failed, so the connection was closed (only used in QSslSocket)
  4. Stan: QAbstractSocket::UnconnectedState
To copy to clipboard, switch view to plain text mode 
I do not know why QList<QSslError> l is empty.