Important: Please read the Qt Code of Conduct -

SslKey on iOS, cannot read private key

  • Hi,

    I created SslServer using Qt and client, which works just fine on Ubuntu. The problem is when I try to port it to iOS.

    When I try to connect I get error on client console: QAbstractSocket::SslInvalidUserDataError
    After some more investigation I found out that iOS cannot load SslKey. It means I cannnot create correct QSslKey object. I can read the file with key, but when I run code:

    QFile file;
    QSslKey key(file.readAll(), QSsl::Rsa);;
    qDebug() << key << file.readAll();

    What I get is

    QSslKey(PrivateKey, RSA, -1) "----- BEGIN PRIVATE KEY-----
    \n-----END PRIVATE KEY-----\n"

    So it looks like Qt cannot read key
    Any ideas?

    EDIT: I forgot, the keys are self-signed, maybe that is the problem?

    EDIT2: Just checked, it also works on Android

  • Lifetime Qt Champion


    Which version of Qt are you using ?

  • I tried both 5.5 and 5.6. And according to the documentation this versions are using Apple's Secure Transport API, what I can confirm using methods:


    Also I checked that changing my server peer verification to VerifyNone works just fine. The problem is that iOS cannot load my ssl key and because of that server cannot verify user.

  • Hi,

    Any one found the solution for this ?
    Even i am facing the same issue in iOS.

    Version Details :-
    Qt 5.6.2
    XCode 8.1
    iOS 10.1


  • You can try this project: link

Log in to reply