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. QTcpServer using QSslSocket, need help with certificates

QTcpServer using QSslSocket, need help with certificates

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.0k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Malisscz
    wrote on last edited by
    #1

    Hello,

    I am trying to create basic SSL server (on Ubuntu 11.04 32bit), using QTcpServer with QSslSockets. I have managed to get it working with my dummy certifacate. But now i got real proper certificate and i am not sure what to add and where. I have recieved 5 files in total: AddTrustExternalCARoot.crt ,myappname.csr, myappname.key, COMODOHigh-AssuranceSecureServerCA.crt and STAR_myappname_com.crt.

    This method is called from QTcpServer::incomingConnection(int socketDescriptor) ... I basicly create QSslSocket, set the descriptor, add my certificates and start handshake...

    So my question then is: Could anyone show me how to properly set the QSslSocket?
    @
    void SSLServerConnection::setSocket(int descriptor){

    sslsocket = new QSslSocket(this);
    sslsocket->setSocketDescriptor(descriptor);
    
    //I am guessing those two are correctly
    sslsocket->setPrivateKey("/home/myname/certs/myappname.key");
    sslsocket->setLocalCertificate("/home/myname/certs/myappname.csr");
    //And now i need to set CA authorities somehow
    //... 
    
    //to my knowledge this tells the socket to ask for valid certificate during ssl handshake
    sslSocket->setPeerVerifyMode(QSslSocket::VerifyPeer);
    
    connect(sslsocket, SIGNAL(encrypted()), SLOT(connectionEncrypted()));
    connect(sslsocket, SIGNAL(disconnected()), SLOT(connectionClosed()));
    connect(sslsocket, SIGNAL(readyRead()), SLOT(readyRead()));
    connect(sslsocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(error(QAbstractSocket::SocketError)));
    
    sslsocket->startServerEncryption();
    
    qDebug() << "New ssl connection:";
    

    }@

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Malisscz
      wrote on last edited by
      #2

      Turns out i was using wrong file for localcertificate. With a proper .crt certificate it works with no problem.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet !

        Great you found out and thanks for sharing the solution

        Can you also please update the thread title prepending [solved] ? So other forum users may know a solution has been found :)

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

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