Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Retired
garydev
Posts: 83
Registered: ‎10-10-2012
My Device: Z30

Re: WebView and SSLErrors

Hi - I spoke with Oros - wrt this specific question, he'd like me to move forward and answer.  I'll continue to investigate.

 

gary

Retired
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10

Re: WebView and SSLErrors

Hi float,

 

Can you expand on what the problem is?

 

WebView should present the user with options to trust / accept and move forward. Can you share a test url?

 

 

Hi Paratheo,

 

Using QtGUI with Cascades is not supported at this time. Both need primary control of the display - QtGUI doesn't seem SSL related - perhaps you should start a different thread.

 

Thanks.

--
Rob is no longer associated with BlackBerry.
Developer
Paratheo
Posts: 134
Registered: ‎04-25-2009
My Device: Z30

Re: WebView and SSLErrors

Hi robbieDubya,

 

I am having the same problem as float... please read the original post again and view this link:

 

http://www.developer.nokia.com/Community/Wiki/How_to_ignore_ssl_errors_to_get_https_website_work_on_...

 

Webview only presents user option to trust/accept sites in OS 10.2.1 and above. For all devices pre 10.2.1, the webview shows a blank white screen. For this reason, float and I are trying to use the solution found in the link above. The example in the link uses 

QmlApplicationViewer 

but the alternative to this is to use QDeclarativeView. Both work, and I've seen examples using both. 

 

Thanks!

 

 

Developer
Paratheo
Posts: 134
Registered: ‎04-25-2009
My Device: Z30

Re: WebView and SSLErrors

[ Edited ]

The other solution to our problem is to subclass WebView in order to take control of the QNetworkReply so that we can ignoreSSLErrors(). Is it possible to access the QNetworkReply of the WebView?

 

 

Retired
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10

Re: WebView and SSLErrors

[ Edited ]

The 'solution' in that link is for an unrelated class that is not supported...

 

ie: if you really want to use QtGui - then an SSL thread isn't the right thread.

--
Rob is no longer associated with BlackBerry.
Developer
Paratheo
Posts: 134
Registered: ‎04-25-2009
My Device: Z30

Re: WebView and SSLErrors

[ Edited ]

Is it really unsupported? CustomNetworkManagerFactory is compiling just fine when i use this include..
#include "customnetworkmanagerfactory.h"
Everything shown in that link is working except for the part where QDeclarativeView is initialized in order to utilize the CustomNetworkManagerFactory class. 

CustomNetworkManagerFactory* myNetworkAccessManagerFactory =
			new CustomNetworkManagerFactory(&app);
	//QScopedPointer<QDeclarativeView> view(new QDeclarativeView());
	QDeclarativeView view;
	view->engine()->setNetworkAccessManagerFactory(
			myNetworkAccessManagerFactory);

I have seen in other threads within this community people are using QDeclarativeView. Perhaps this is for pure Qt projects... thats fine. But is there any other way that the solution shown in the link can be implemented? Any way to assign the networkAccessManagerFactory as shown above?

And if not... how else can we manage to take control of the QNetworkReply in order to bypass the SSLErrors. This issue is very important for me because my app SoundNine uses OAuth for login with WebView and there are issues with the certificates on the device that won't allow the login page to load. With the regular API calls I use, i can ignore the SSL errors in the QNetworkReply and thats fine. But I need some way to control that in the WebView so users can login! 

Thanks!

Retired
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10

Re: WebView and SSLErrors

Hi,

 

You can change the declaritive engine's network access manager:

 

MyFac fac(QmlDocument::defaultDeclarativeEngine()->networkAccessManagerFactory());

QmlDocument::defaultDeclarativeEngine()->setNetworkAccessManagerFactory(
			&fac);

 But the next problem is that the WebView doesn't use that network access manager / factory to connect to the web.

 

The only requests you see through that manager are requests for assets.

 

Here's my suggestion:

 

  • Use the WebView to connect to:
    • http://localhost:somerandomport (not https)
  • Have a server running on that port which:
    • Is a proxy for the host you want to connect to
    • It manages the SSL connection
      • You'll get richer feature control like (for example) TLS client certificates.

Considerations:

  • Proxy server would need to rewrite the Host header
  • Proxy server may need to rewrite http responses for servers which return absolute URLs.
  • Proxy server may need to try multiple ports before its allowed to listen
  • Ensure only your app is using the proxy by: 
    • Generate a long random number per instance
    • Add it to the headers using the WebSettings in the WebView
    • Disconnect clients that do not submit that header

 

Thanks.

--
Rob is no longer associated with BlackBerry.
Developer
Paratheo
Posts: 134
Registered: ‎04-25-2009
My Device: Z30

Re: WebView and SSLErrors

[ Edited ]

Thank you for this info! However, I haven't got the slightest clue about implementing your suggestion. I will begin searching around...

 

I'm curious. Seeing as how that network access manager is only used for assets, surely there must be one specifically for the WebView component. Is that factory completely unaccessible? 

 

One of my earlier ideas for this problem was to download the html of each page manually in a QNetworkRequest and then assign the html to the WebView. I could control the QNetworkReply to ignore the SSLErrors. For the most part, this worked, except that the CSS and javascript of the page were not loaded because those url's within the html were blocked by SSL Errors. That's why I realized that I needed a way to more broadly control the QNetworkManager for the WebView. 

 

And just to clarify... subclassing the WebView isn't a viable option? I appreciate the solution that you suggested but it certainly looks complicated.

 

Thanks!

Retired
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10

Re: WebView and SSLErrors

[ Edited ]

Hi,

 

Attached is a really rough sketch of how this can be done.

 

Works with my Tomcat installation (which has a bad cert)

 

Minimal QML:

 

Page {
    Container {
        WebView {
            url: app.proxyURL
        }
    }
}

 

Config in application class:

 

	_proxy = new HttpsProxy(this);

	_proxy->setTargetHost("169.254.0.2");
	_proxy->setTargetPort(8443);

That makes the WebView go via the proxy to https://169.254.0.2:8443 - which - for my setup - is the Tomcat test server.

 

Thanks. 

 

 

 

--
Rob is no longer associated with BlackBerry.
Developer
Paratheo
Posts: 134
Registered: ‎04-25-2009
My Device: Z30

Re: WebView and SSLErrors

Thank you so much for this!!

 

I played around with it. I set the target url to the OAuth login webpage address and i didnt set the port because I dont know it. Now in the debug logs I see it shows first "Connection: close" and then it seems to go again and show "Host: https://soundcloud.com/connect?scope=dgkjj....."

Perhaps this is a redirect? I'm not sure what to make of this... but the outputs to the log are coming from the HttpsProxyConnection.cpp file under the processHeaders() method. 

 

As for the WebView itself, it shows an error page and says "Server returned nothing (no headers, no data). 

Any ideas?

Thanks!