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. QSsl client + server, working example
QtWS25 Last Chance

QSsl client + server, working example

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 6.8k 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.
  • L Offline
    L Offline
    luca
    wrote on 25 Oct 2012, 13:48 last edited by
    #1

    Hi all,
    I'm trying to get my client + server applications working with QSslSocket.

    The problem is that I can't find a good working example.

    I found a client example in QtSDK examples but not the server one.

    Have you got a good example to post?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      luca
      wrote on 26 Oct 2012, 11:49 last edited by
      #2

      I found a working server example:
      @
      m_socket = new QSslSocket(this);
      m_socket->setSocketDescriptor(handle);
      m_socket->setProtocol(QSsl::SslV3);

      QByteArray key;
      QByteArray cert;
      
      QFile file_key("../ssl/server.key");
      if(file_key.open(QIODevice::ReadOnly))
      {
          key = file_key.readAll();
          file_key.close();
      }
      else
      {
          qDebug() << file_key.errorString();
      }
      
      QFile file_cert("../ssl/server.crt");
      if(file_cert.open(QIODevice::ReadOnly))
      {
          cert = file_cert.readAll();
          file_cert.close();
      }
      else
      {
          qDebug() << file_cert.errorString();
      }
      
      //qDebug() << key + "\n" + cert;
      
      
      QSslKey ssl_key(key, QSsl::Rsa);
      
      QSslCertificate ssl_cert(cert);
      
      m_socket->setPrivateKey(ssl_key);
      m_socket->setLocalCertificate(ssl_cert);
      m_socket->startServerEncryption();
      

      @

      This example works fine.

      Now how can I avoid certificate sending to client?
      I'd like to have the certificate already available to the client code so that it can use that certificate to communicate with server .

      1 Reply Last reply
      0

      1/2

      25 Oct 2012, 13:48

      • Login

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