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 and QTcpSocket ... how to know if the connection is incorrect

QSslSocket and QTcpSocket ... how to know if the connection is incorrect

Scheduled Pinned Locked Moved Unsolved General and Desktop
qsslsocketqtcpsocket
3 Posts 3 Posters 1.1k 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
    healermagnus
    wrote on 18 Jun 2019, 16:22 last edited by
    #1

    I have a TCP client and server, and either can be in SSL mode or not, depending on use case. It took me a while to get the two to talk to each other in SSL mode, but that seems to be working now.

    What's confusing is that if one of the sides is not set to SSL mode, it doesn't seem to fail via disconnect. Either I'm missing a signal listener, or I don't actually have SSL mode working.

    It would seem that if either side is set to SSL and the other is not, either a disconnect should happen, or a signal is sent that I can create a handler for. The side that is set to SSL should not like the data from the non-SSL side during handshake, and something should happen.

    I admit, I'm not sending anything over the line yet, and maybe that is the moment that a disconnect happens?

    Any ideas what I'm missing?

    P K 2 Replies Last reply 18 Jun 2019, 17:54
    0
    • H healermagnus
      18 Jun 2019, 16:22

      I have a TCP client and server, and either can be in SSL mode or not, depending on use case. It took me a while to get the two to talk to each other in SSL mode, but that seems to be working now.

      What's confusing is that if one of the sides is not set to SSL mode, it doesn't seem to fail via disconnect. Either I'm missing a signal listener, or I don't actually have SSL mode working.

      It would seem that if either side is set to SSL and the other is not, either a disconnect should happen, or a signal is sent that I can create a handler for. The side that is set to SSL should not like the data from the non-SSL side during handshake, and something should happen.

      I admit, I'm not sending anything over the line yet, and maybe that is the moment that a disconnect happens?

      Any ideas what I'm missing?

      P Offline
      P Offline
      Pablo J. Rogina
      wrote on 18 Jun 2019, 17:54 last edited by
      #2

      @healermagnus it would be great if you share your code as how you're using QTcpSocket or QSslSocket.

      For the later, I guess it's mandatory that you connect to the sslErrors signal

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      3
      • H healermagnus
        18 Jun 2019, 16:22

        I have a TCP client and server, and either can be in SSL mode or not, depending on use case. It took me a while to get the two to talk to each other in SSL mode, but that seems to be working now.

        What's confusing is that if one of the sides is not set to SSL mode, it doesn't seem to fail via disconnect. Either I'm missing a signal listener, or I don't actually have SSL mode working.

        It would seem that if either side is set to SSL and the other is not, either a disconnect should happen, or a signal is sent that I can create a handler for. The side that is set to SSL should not like the data from the non-SSL side during handshake, and something should happen.

        I admit, I'm not sending anything over the line yet, and maybe that is the moment that a disconnect happens?

        Any ideas what I'm missing?

        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 18 Jun 2019, 21:13 last edited by
        #3

        @healermagnus said in QSslSocket and QTcpSocket ... how to know if the connection is incorrect:

        Any ideas what I'm missing?

        You want a delayed handshake. Ideologically it goes like this:
        You create the QSslSocket object, but operate it as a QTcpSocket. The server and client exchange TCP messages (as per your liking) to try and negotiate whether they should stay in plain TCP or in SSL mode. When the connection is decided to be used over SSL the client calls startClientEncryption, while the server socket calls startServerEncryption to begin the actual SSL handshake. Connecting the TCP error and sslErrors() signals is a must.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        1

        1/3

        18 Jun 2019, 16:22

        • Login

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