[Qt-interest] Using QSslSocket with QTcpServer results in segfault

Nikos Chantziaras realnc at arcor.de
Sun Dec 6 08:50:54 CET 2009


Hello.  This is on Linux 64-bit with Qt 4.5.3.

I am trying to introduce SSL in the "Fortune Server" example:

   http://doc.trolltech.com/4.5/network-fortuneserver.html

I followed the example given in the Qt docs here:

   http://doc.trolltech.com/4.5/qsslsocket.html#details

So I override QTcpServer::incommingConnection(int) with the example 
implementation given there, plus three more lines in order to use SSLv2 
(just in case the problem was the SSL version used) and setup key and 
certificate:

   void SslServer::incomingConnection(int socketDescriptor)
   {
     QSslSocket *serverSocket = new QSslSocket;
     serverSocket->setProtocol(QSsl::SslV2); // Shotgun debugging.
     serverSocket->setPrivateKey("privkey.pem");
     serverSocket->setLocalCertificate("cacert.pem");
     if (serverSocket->setSocketDescriptor(socketDescriptor)) {
       connect(serverSocket, SIGNAL(encrypted()), this, SLOT(ready()));
       serverSocket->startServerEncryption();
     } else {
       delete serverSocket;
     }
   }

The SslServer::ready() slot has just a

   qDebug() << "ready() called.";

line in it.

The key and self-signed certificate reside in the same directory as the 
application and have been created with:

   openssl genrsa -out privkey.pem 2048
   openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095

The rest of the "Fortune Server" app stays the same.  However, when 
connecting to the server, the application crashes instantly with:

   QObject::connect: Cannot connect (null)::disconnected() to
   (null)::deleteLater()
   Segmentation fault

What am I doing wrong?




More information about the Qt-interest-old mailing list