I have to secure my data sharing program (i use QTcpServer i QTcpSocket). I decided to use QSslSocket and began from the simple examples from the internet. At the beginning I encountered the problem that I can not solve. I downloaded Win32OpenSSL_Light-1_0_0d and generated a key and certificate in accordance with Guide to SSL certificates and certificate authorities

Next I created a server and client. When trying to connect my server throws an error. Similarly, when trying to connect to server via the client securesocketclient example from the documentation.
Qt Code:
  1. Error during SSL handshake: error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher
To copy to clipboard, switch view to plain text mode 
Certificates are in server directory, paths is correct.

Please help in resolve the problem.

Qt Code:
  1. class SslServer : public QTcpServer
  2. {
  3. Q_OBJECT
  4. QSslSocket *serverSocket;
  5.  
  6. public:
  7. SslServer(QObject *parent = 0);
  8.  
  9. void start(quint16 port);
  10. void incomingConnection(int socketDescr);
  11.  
  12. public slots:
  13. void readyToRead();
  14. void sslErrors(QAbstractSocket::SocketError error);
  15.  
  16. };
  17.  
  18. SslServer::SslServer(QObject *parent) :
  19. QTcpServer(parent)
  20. {
  21. }
  22.  
  23. void SslServer::start(quint16 port)
  24. {
  25. listen(QHostAddress::Any, port);
  26. }
  27.  
  28. void SslServer::readyToRead()
  29. {
  30. //qDebug() << this->serverSocket->readAll();
  31. }
  32.  
  33. void SslServer::sslErrors(QAbstractSocket::SocketError error)
  34. {
  35. qDebug() << serverSocket->errorString();
  36. }
  37.  
  38. void SslServer::incomingConnection(int socketDescr)
  39. {
  40. serverSocket = new QSslSocket;
  41. if(serverSocket->setSocketDescriptor(socketDescr))
  42. {
  43. connect(serverSocket, SIGNAL(readyRead()), this, SLOT(readyToRead()));
  44. connect(serverSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(sslErrors(QAbstractSocket::SocketError)));
  45. serverSocket->setProtocol(QSsl::SslV3);
  46. serverSocket->setPrivateKey("ca.key");
  47. serverSocket->setLocalCertificate("ca.cer");
  48. serverSocket->startServerEncryption();
  49. }
  50. else
  51. {
  52. delete serverSocket;
  53. }
  54. }
To copy to clipboard, switch view to plain text mode