Results 1 to 1 of 1

Thread: QSslSocket problem with ssl certificates

  1. #1
    Join Date
    Apr 2014
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QSslSocket problem with ssl certificates

    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:
    Qt Code:
    1. void incomingconnection(int d) {
    2. QSslSocket * socket = new QSslSocket();
    3. if(socket->setSocketDescriptor(d)) {
    4. //here I am writing the code described below.
    5. socket->startServerEncryption();
    6. ...
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    First case:
    Qt Code:
    1. socket->setLocalCertificate("domain.crt");
    2. socket->setPrivateKey("domain.key");
    To copy to clipboard, switch view to plain text mode 

    This code works. But if I write like this:
    Qt Code:
    1. QFile certfile("domain.pem");
    2. certfile.open(QIODevice::ReadOnly);
    3. QList<QSslCertificate> certList;
    4. QSslCertificate cert(&certfile, QSsl::Pem);
    5. certList.push_back(cert);
    6. socket->setCaCertificates(certList);
    To copy to clipboard, switch view to plain text mode 

    An error has occurred, which can be seen in the browser Google Chrome:
    Qt Code:
    1. 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 .
    2. Error Code : ERR_SSL_PROTOCOL_ERROR
    To copy to clipboard, switch view to plain text mode 

    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:
    Qt Code:
    1. openssl req-nodes-newkey rsa: 2048 -keyout domain.key-out domain.csr
    2. openssl x509-req-days 3650 -in domain.csr-signkey domain.key-out domain.crt
    3. ------ CONVERTING to PEM -------
    4. openssl x509-in domain.crt-out domain.der-outform DER
    5. openssl x509-in domain.der-inform DER-out domain.pem-outform PEM
    To copy to clipboard, switch view to plain text mode 

    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.
    Last edited by folov; 30th April 2014 at 21:07.

Similar Threads

  1. SSLServer + certificates
    By eleanor in forum Qt Programming
    Replies: 1
    Last Post: 5th April 2016, 20:09
  2. View certificates in linux
    By mania in forum General Discussion
    Replies: 8
    Last Post: 11th December 2013, 05:07
  3. Getting p12 certificates already installed in system.
    By sargsyan.taron in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2011, 16:25
  4. Replies: 1
    Last Post: 5th October 2009, 16:40
  5. SSL handshaking without certificates
    By palas in forum Qt Programming
    Replies: 6
    Last Post: 5th August 2008, 22:46

Tags for this Thread

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.