View Full Version : QSslSocket problem with ssl certificates

30th April 2014, 21:26
hi community qt.
I'm trying to create ssl connection. As a client I use browser. As a server I use QTcpSocket. When there is a new method connectings I called incommingconnection (), which belongs to the class QTcpServer.
Here's the code:

void incomingconnection(int d) {
QSslSocket * socket = new QSslSocket();
if(socket->setSocketDescriptor(d)) {
//here I am writing the code described below.

First case:


This code works. But if I write like this:

QFile certfile("domain.pem");
QList<QSslCertificate> certList;
QSslCertificate cert(&certfile, QSsl::Pem);

An error has occurred, which can be seen in the browser Google Chrome:

Unable to make a secure connection to the server. On the server could be a problem , or need a client authentication certificate that you do not have .

As can be seen in the first case, I use a separate crt and key file. A second file I use domain.pem.
I got these files with the following commands:

openssl req-nodes-newkey rsa: 2048 -keyout domain.key-out domain.csr
openssl x509-req-days 3650 -in domain.csr-signkey domain.key-out domain.crt
------ CONVERTING to PEM -------
openssl x509-in domain.crt-out domain.der-outform DER
openssl x509-in domain.der-inform DER-out domain.pem-outform PEM

Maybe I'm wrong generate pem file, maybe I incorrectly recorded a second code example. I do not know exactly. I ask you to give me an example of generation pem file for use with qt ( socket->setCaCertificate(cert) ) or say in what I have here an error.

Thank you very much.