Important: Please read the Qt Code of Conduct -

Minimal working example of QWebEngine with client certificates?

  • I am trying to get client certificates working with the Qt web engine (version 5.15), but I can't seem to get it done!

    I have a local server set up to use SSL, to expect client certificates and check them against a locally created root CA certificate. The client on the other hand, has a client certificate, signed by this local root CA.

    This is as far as I can whittle it down ... which might be too far, causing the problems!

    #include <QApplication>
    #include <QtWebEngine>
    #include <QWebEngineProfile>
    #include <QWebEngineView>
    class MyWebPage : public QWebEnginePage
        MyWebPage(QObject * Parent) :
            QObject::connect(this, &QWebEnginePage::selectClientCertificate, this, &MyWebPage::SelectClientCertificate);
        auto certificateError(QWebEngineCertificateError const & CertificateError) -> bool override
            return true;
        auto SelectClientCertificate(QWebEngineClientCertificateSelection ClientCertificateSelection) -> void
    auto main(int argc, char *argv[]) -> int
        auto Application = QApplication{argc, argv};
        auto WebView = QWebEngineView{};
        WebView.resize(1024, 750);;
        auto ClientCertificateFile = QFile{"client.pem"};;
        auto ClientCertificate = QSslCertificate{&ClientCertificateFile};
        auto PrivateKeyFile = QFile{"client.key"};;
        auto PrivateKey = QSslKey{&PrivateKeyFile, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey};
        auto WebPage = MyWebPage{&WebView};
        WebPage.profile()->clientCertificateStore()->add(ClientCertificate, PrivateKey);
        return Application.exec();

    What I get is an error message in the browser window with "ERR_SSL_CLIENT_AUTH_NO_COMMON_ALGORITHMS" - so apparently browser and server don't know how to talk to each other.

    I've tried curl and it works fine with either

    curl --tlsv1.2 --tls-max 1.2 --insecure https://localhost/ --cert client.certificate.pem --key client.private_key.key


    curl --tlsv1.3 --tls-max 1.3 --insecure https://localhost/ --cert client.certificate.pem --key client.private_key.key

    I've tried deactivating client certificates on the server side and it works fine.

    Are there any problems with my example? Did I miss some initialization steps or something?

    Maybe my example WOULD be working - if only the client and server knew how to talk to each other, so that, consequently, the error really is in the cipher suites?! Is there any way I can check the exchanged and possible algorithms? Ultimately, I find that very unlikely, as we're talking about a Chrome backend on the client side talking to an Apache server, both of which are hugely popular ...

    Any hints?

    Thank you for any help you can offer and best regards!

Log in to reply