Secure websockets and QtWebKit - Qt SDK 4.8 (VS2008)



  • Hello,

    My app contains a QtWebKit control.

    I'm able to use unsecured websockets to an apache web server, but when I try to use wss://, I get disconnected right away without any error message.

    I have connected to the following site with my app and it confirms that regular websockets are ok, but not wss:
    http://websocket.org/echo.html

    I get a disconnect right away.

    any ideas?



  • Have you compiled Qt with openssl? Have you connected slot
    @void sslErrors(QNetworkReply * reply, const QList<QSslError> &)@



  • @AcerExtensa

    Yes, I do connect to this slot and I'm ignoring all ssl errors, otherwise I get blank pages.

    I did not compile Qt - I'm using Qt SDK 1.2 (4.8.0 vs2008).

    Thanks for that info, it looks like I need to download OpenSSL.



  • @AcerExtensa
    I still can't connect using TLS even after installing OpenSSL - my guess it is due to an outdated protocol used by the version of webkit that is part of 4.8.0.



  • Try to clone git repository of qt(it has qt 4.8.1 & Webkit 2.2.2) and build it by yourself...



  • It should work! I've tested it: !http://vip2006.net/wss_qt.png(Qt WSS Test)!



  • Thank you for confirming that it works - that looks very promising.
    Finally after trying all day to clone git, I'm building right now with mingw.
    What compiler did you use - can you show the options you used for configure?



  • I'm using VS2010 tools. Here is my configure options:
    @configure -opensource -shared -mp -arch windows -no-declarative-debug -script -webkit -openssl -qmake -vcproj -platform win32-msvc2010 -no-qt3support -nomake examples -nomake demos -qt-style-windows -qt-style-windowsxp -qt-style-windowsvista -mmx -sse -sse2 -process -plugin-manifests -no-fast
    @

    also, I'm using openssl 1.0.1 libs from "this binary packet":http://www.slproweb.com/download/Win32OpenSSL-1_0_1.exe.
    Just install it and copy libeay32.dll & ssleay32.dll from bin folder of openssl installation in the bin folder of Qt. libeay32.lib & ssleay32.lib from openssl lib folder in Qt folder. And openssl folder from openssl in include folder of Qt. :)



  • And my QWebSettings looks like that:

    @QWebSettings * sett = this->view->settings()->globalSettings();

    sett->setAttribute(QWebSettings::JavaEnabled, true);
    sett->setAttribute(QWebSettings::PluginsEnabled,true);
    sett->setAttribute(QWebSettings::AutoLoadImages,true);
    sett->setAttribute(QWebSettings::LinksIncludedInFocusChain,true);
    sett->setAttribute(QWebSettings::ZoomTextOnly,true);
    sett->setAttribute(QWebSettings::PrintElementBackgrounds,true);
    sett->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled,true);
    sett->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled,true);

    #if QT_VERSION >= 0x040800
    sett->setAttribute(QWebSettings::LocalStorageEnabled,true);
    sett->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls,true);
    sett->setAttribute(QWebSettings::AcceleratedCompositingEnabled,true);
    sett->setAttribute(QWebSettings::LocalContentCanAccessFileUrls,true);
    sett->setAttribute(QWebSettings::DnsPrefetchEnabled, true);
    #endif
    sett->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
    sett->setAttribute(QWebSettings::JavascriptEnabled,true);
    #if QT_VERSION >= 0x040800
    sett->setAttribute(QWebSettings::JavascriptCanCloseWindows, true);
    #endif
    sett->setAttribute(QWebSettings::JavascriptCanAccessClipboard,true);

    #if QT_VERSION >= 0x040800
    sett->setAttribute(QWebSettings::SiteSpecificQuirksEnabled, true);
    #endif
    @



  • turns out there was some problem with my computer. I just installed Qt SDK 1.2 (Qt 4.8.0, mingw) on another computer and everything works just fine running the same code. I did have to install openSSL though. I wasted a week on this, but I'm glad it works now.
    Thanks for your help.



  • Hi,
    I have tried to build qt with the steps from this site:
    http://www.holoborodko.com/pavel/2011/02/01/how-to-compile-qt-4-7-with-visual-studio-2010/
    with the following:
    Qt 4.8.4, VisualStudio2010, OpenSSL v1.0.1,

    I needed to build Qt since I can not access https sites. so I have tried to build with openssl.
    I followed the build steps and added the open ssl:

    configure.exe -platform win32-msvc2010 -opensource -shared -debug-and-release -openssl-linked -I C:\OpenSSL-Win32_full\include\openssl -L C:\OpenSSL-Win32_full\lib

    I have installed open ssl under C:\OpenSSL-Win32_full

    After build of Qt was done, I have tried to build and run the previewer example from the Qt installation dir.
    There I have tried to load http url and it worked fine, when I tried to load https url nothing happened. the page was blank.

    I tried to see if ssl is supported by adding :

    bool isSSL = QSslSocket::supportsSsl();

    I get isSSL = true.

    Does anyone have an idea why https does not work?

    Thanks in advance.



  • And what does it have to do with current Topic? Create new forum topic and describe your problem there...
    In any way, have you connected to SSlError SLOT? what what does returned error string from NetworkReply says when you try to connect to https?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.