QSslSocket



  • A bit ago I wrote a simple SSL socket client server pair, even did a bit of client certificate authenticaion as well as using a server socket.

    Now I just cannot get it to work....worse still it simply does nothing - no error messages, no crash, no app. stall. All that happens is the client socket connects, server calls the startServerEncryption but then no events are fired. Neither "normal" socket error signal fires, nor ssl error signal.

    I've checked the validity of the local certificate and key with isNull() and both return success.

    I've recompiled OpenSSL with Visual Studio 2013, I've tried Qt5.4 and 5.5.1 - both behave the same.

    I've simplified the apps to use a browser as the client - exactly the same.

    So looks as though SSL negotiation not working, or trying so I'm completely stuck not now knowing what to even try...



  • ...I've checked validity of my certificate and key...and made sure they match - they do.

    I've simplified the app as much as I can, changed Qt versions, changed OpenSSL versions.

    I've checked I know explicitly where it's getting its dependencies (sysinternals processExplorer) and that they're the right ones.

    I remain baffled - this is an app that used to work and yet something must have changed.

    My concern really is that it fails completely silently...makes it very difficult to trace...


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What version of OpenSSL are you using ?

    Did you try with the pre-built version ?



  • @SGaist I've been round this loop before to get it working last time round.

    Qt creator itself uses openssl and I think I stole the DLLs from that.

    Didn't work this time...so keen to investigate every option I built OpenSSL from source (like OpenSSLs website suggests!) - easy enough, doesn't take long, shame though it made no difference! Qt Creator's DLL's are "1.0.2", I built 1.0.2f from fresh download.

    Further investigation shows both server and client QSslSockets change their mode to client/server appropriately, but there's something that means the SSL handshake just doesn't complete, nor return an error so it just stalls.


  • Lifetime Qt Champion

    Qt Creator's compiler doesn't necessary match the one used for a given platform at a given time so you should rather take a look for the Official Release of OpenSSL



  • @SGaist Thanks for your thoughts - I was happy that my fresh-build of OpenSSL was clean, and then matched my current compiler.

    No progress no matter what I try - socket connects ok to TCP server, then startClientEncryption / startServerEncrytion called at the appropriate ends of the link but still no more events (other than the expeceted mode change) and still no errors....very frustrating! A whole day lost....


  • Lifetime Qt Champion

    Strange… If I've read correctly you have written a smaller version of your application that shows that behavior, can you share it ?



  • @SGaist - thanks for chipping in on this one.

    I think I've literally just this second found it....in setting the socketdescriptor I was also setting the socket to QIODevice::Text.

    Funnily enough, now that's not there it works. How that crept in I do not know....

    The only troubling thing is the way it failed to work without complaining of anything at all.

    I shall put that one down as "one of those things" and admire my own persistence (we'll gloss over my ineptitude).


  • Lifetime Qt Champion

    That's tricky… Good catch !


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.