Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSslSocket addCaCertificates() missing in documentation?
Qt 6.11 is out! See what's new in the release blog

QSslSocket addCaCertificates() missing in documentation?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 473 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    halfgaar
    wrote on last edited by
    #1

    I was trying to set up an SSL server by inheriting from QTcpServer but could not get the handshake done. Either there were no bytes sent to the client, or when I left out QSslSocket::setLocalCertificateChain(), it worked, but no chain was sent (as tested with openssl s_client -connect). Then I just went through the autocomplete list in QtCreator, and found QSslSocket::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 calling startServerEncryption().

    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;
    	}
    }
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      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

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved