[Interest] QSslSocket with a self-signed certificate

Konstantin Shegunov kshegunov at gmail.com
Thu Nov 22 13:09:38 CET 2018


Hello,
I'm struggling to get an SSL connection established between a server and a
client of mine using a self-signed certificate. The SSL handshake fails but
I can't seem to find out why. Here's what I did:

For the server:

1) I generated a key and certificate.
2) I've set them to the socket like this:
socket->setPrivateKey(keyFile);
socket->setLocalCertificate(certificateFile);
3) I call QSslSocket::startServerEncryption to get the handshake rolling.


For the client:

1) I used the server's certificate and loaded it (verified it loads
properly).
2) I set it to the socket with QSslSocket::addCaCertificate.
3) I call QSslSocket::startClientEncryption.


The problem is the client drops the connection with
QAbstractSocket::SslHandshakeFailedError, however I get nothing from the
QSslSocket::sslErrors signal (also nada from the method).

I observed, however, that the client socket raises the
QSslSocket::preSharedKeyAuthenticationRequired for some reason. As I don't
really handle this one (only debug output) I imagine this is the reason the
handshake fails. Nonetheless, I thought a PSK authentication shouldn't be
required whenever I provide a key and a certificate server-side.

Any ideas why is this failing and how to solve it?

Thanks in advance!
Kind regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181122/49a5c3f2/attachment.html>


More information about the Interest mailing list