Results 1 to 7 of 7

Thread: QSslSocket problems

  1. #1
    Join Date
    Sep 2007
    Location
    London
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QSslSocket problems

    Hi,

    I'm currently developping with Qt 4.3.1 on Windows XP SP2 using VS2005 SP1. I'm trying to get a SSL Server to work. Both the ssl client and the ssl server are Qt project and are run on the same machine. I'm using ip address 127.0.0.1 and I have installed openssl for windows from http://www.slproweb.com/products/Win32OpenSSL.html.

    The structure for the client is to have a QThread create the ssl socket in the run method, connect the socket to the thread slot using Queued connections and try connecting to the ssl server by calling connectToHost. When the socket raises the connected signal, the socket then calls startClientEncryption.

    The ssl server program starts a QThread that creates an ssl server. On receiving on incoming connection, the server creates an ssl socket, sets the descriptor. The Thread then connects the socket to its own slots using queued connections and then calls startServerEncryption.

    No error occurs so far. Then the following error messages appears in the client ouput : "QSocketNotifier: socket notifiers cannot be enabled from another thread".

    If I try creating a ThreadNotifiger object in the client thread and connect that to the ssl socket, the server falls over with an UnknownSocketError and the connection is broken.

    I have tried changing the nature of the connections, changing the ssl protocl, creating the client socket in main UI client thread. Nothing has worked. Sometimes the server crashes or I always get the UnknowSocketError. No SSL errors are raised. The server error string is empty.

    I have tried to check the Qt documents about which version of openssl I should be using. I couldn't fing anything about this.

    Does anyone have any advice about how to get this to work ?

    Thanks,
    Pascal.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSslSocket problems

    Make sure that you call setEnabled() from the same thread where the notifier was created. Remember that the thread object does not live in its own thread! Thus if the notifier is a member of your QThread subclass, it won't work.

  3. #3
    Join Date
    Sep 2007
    Location
    London
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSslSocket problems

    I should have explained that the ThreadNotifier class is my own class. It's not derived from QSocketNotifier. It gets created inside the thread run method using new.

    I should also add that the ssl server is derived from QTcpServer with nextPendingConnection and incomingConnection overridden.

    Am I supposed to call both startClientEncryption and startServerEncrytption or only one of them ?

    And which version of the ssl libs am I supposed to use with Qt 4.3.1 ?

    Thanks for your input,
    Pascal.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSslSocket problems

    Quote Originally Posted by TheOnlyDan View Post
    I should have explained that the ThreadNotifier class is my own class. It's not derived from QSocketNotifier. It gets created inside the thread run method using new.
    Qt complains about QSocketNotifier, not ThreadNotifier. One way or the other your calling objects accross threads.

    And which version of the ssl libs am I supposed to use with Qt 4.3.1 ?
    That doesn't matter. SSL is not a problem here.

  5. #5
    Join Date
    Sep 2007
    Location
    London
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSslSocket problems

    I have fixed the problem of messages crossing threads but now the ssl server falls over with an UnkwonSocketError.

    Everything seems to work fine if I don't try to do the ssl encryption handshake. I am using default configured ssl sockets. Do they need to be properly configured beforehand ?

    Cheers,
    Pascal.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

  7. #7
    Join Date
    Sep 2007
    Location
    London
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSslSocket problems

    Thanks for the links. I'll check them out.

    Cheers,
    Pascal.

Similar Threads

  1. Replies: 2
    Last Post: 8th March 2007, 22:22
  2. Problems with Unicode(UTF8)
    By cristiano in forum Qt Programming
    Replies: 15
    Last Post: 5th December 2006, 12:33
  3. Utf8 problems
    By cristiano in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2006, 00:14
  4. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39
  5. problems with Opengl
    By SlawQ in forum Qt Programming
    Replies: 4
    Last Post: 12th February 2006, 22:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.