9

I have a QML Image object with source pointing to a https server I control, the server has a self signed CA certificate.

Is there a global SSL configuration of some sort where I could trust my self signed certificate? I know it is possible to set a SslConfiguration when doing a request through Qt in C++, but how do I do it if I make the request (implicitly) through QML?

EvenLisle
  • 4,672
  • 3
  • 24
  • 47
  • 2
    did you try static method `void QSslConfiguration::setDefaultConfiguration(const QSslConfiguration &configuration)` in C++ side of your qml app ? – Redanium Mar 11 '18 at 19:45

1 Answers1

0

You could make a wrapper class for the SSL Connection in C++ then simply add the metatype of your wrapper class to the QML engine with

qmlRegisterMetaType<SSLWrapper>("com.your.app", 1, 0, "SSLWrapper"); from C++

and

import com.your.app 1.0 from qml

This would allow you to create an instance of your C++ class using:

SSLWrapper { id: my_wrapper }

and then grab the image from your remote server using a native C++ method that has been prefixed by Q_INVOKABLE in order to access it from QML, then convert it into bytes and send it over a signal/slot setup to pass the bytes and then set the Image URL that you want to import to use data string for the image which you would get from the SSLWrapper's signal

Also check out Qt/QML : Send QImage From C++ to QML and Display The QImage On GUI

mike510a
  • 2,102
  • 1
  • 11
  • 27