QSslSocket addCaCertificates() missing in documentation?
-
I was trying to set up an SSL server by inheriting from
QTcpServerbut could not get the handshake done. Either there were no bytes sent to the client, or when I left outQSslSocket::setLocalCertificateChain(), it worked, but no chain was sent (as tested withopenssl s_client -connect). Then I just went through the autocomplete list in QtCreator, and foundQSslSocket::addCaCertificates(). That worked.I'm using Qt 5.9.5, but even when I inspect header files for 5.12,
QSslSocket::addCaCertificates()(and singular) methods aren't deprecated. Shouldn't they be in the page for QSslSocket? There is no other mention of making sure sending chains works when callingstartServerEncryption().For the record, this is the overridden
incomingConnection():void SslServer::incomingConnection(qintptr socketDescriptor) { QSslSocket *serverSocket = new QSslSocket; if (serverSocket->setSocketDescriptor(socketDescriptor)) { serverSocket->addCaCertificates(chainCerts); serverSocket->setLocalCertificate(cert); serverSocket->setPrivateKey(sslKey); connect(serverSocket, QOverload<const QList<QSslError> &>::of(&QSslSocket::sslErrors), this, &SslServer::onSslErrors); connect(serverSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError))); serverSocket->startServerEncryption(); addPendingConnection(serverSocket); } else { delete serverSocket; } } -
Looks like a documentation bug. I'll upload a patch.
I misread your post. addCaCertifcates() is deprecated: https://doc.qt.io/qt-5/qsslsocket-obsolete.html