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

Adobe AIR Development

Reply
Highlighted
New Contributor
Posts: 5
Registered: ‎11-03-2011
My Device: Non-blackberry user
My Carrier: non-blackberry user
Accepted Solution

QNXStageWebView and self-signed certificates

I'm using QNXStageWebView control to load HTML pages in my AIR application. I'm testing with OS version 1.0.7.3133 and AIR version 2.7 and Tablet OS SDK is 1.1.0.  When I use https and try to access a web site which uses a self-signed certificate (which is not trusted on the device), the object of QNXStageWebView does not throw any error events. How can I detect that the user is trying to access an untrusted website and warn him (like the native browser does)? I saw Wireshark logs and I see an "Handshake Failure" error.

Retired
Posts: 172
Registered: ‎06-07-2010
My Device: BlackBerry 8520
My Carrier: Rogers

Re: QNXStageWebView and self-signed certificates

Hello Kiran,

 

How are you doing? I hope all is well.

 

In regards to your question have you tried validating the page via the boolean QNXStageWebView.certificateInfo.rejectedFlags.isErrorNotTrusted?

 

You can work your logic so that when the page has finished loading via WebViewEvent.DOCUMENT_LOAD_FINISHED you can check for the above boolean and prompt a dialog informing the user that the page isn't trusted.

 

Let me know if this does not suit your need.

 

Sincerely,

Raihan Masroor
BlackBerry Development Advisor
New Contributor
Posts: 5
Registered: ‎11-03-2011
My Device: Non-blackberry user
My Carrier: non-blackberry user

Re: QNXStageWebView and self-signed certificates

Hi Raihan,

 

Thanks for your response. I'm listening for WebViewEvent.DOCUMENT_LOAD_FINISHED on the web view object. But, I don't see that event being triggered. Any ideas why? I use the native PlayBook brower, it pops up the certificate dialog for the same web site.

 

Thanks,

Kiran

Retired
Posts: 172
Registered: ‎06-07-2010
My Device: BlackBerry 8520
My Carrier: Rogers

Re: QNXStageWebView and self-signed certificates

Hey Kiran,

 

My event is sucessfully able to trigger events. The code I use is a slightly altered code found on the QNX example via http://www.blackberry.com/developers/docs/airapi/1.0.0/qnx/media/QNXStageWebView.html

 

package
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.geom.Rectangle;
    import flash.utils.Timer;
    import qnx.events.WebViewEvent;
    import qnx.media.QNXStageWebView;
    import qnx.ui.events.
    import qnx.ui.progress.PercentageBar;
    [SWF(height="600", width="1024", frameRate="30", backgroundColor="#FFFFFF")]
    public class MyStageWeb extends Sprite
    {
        private var mySwv:QNXStageWebView;
        private var myProgress:PercentageBar;
        private var timer:Timer;
        public function MyStageWeb()
        {
            initializeUI();
        }
        public function initializeUI():void
        {
            timer = new Timer(500);
            timer.addEventListener(TimerEvent.TIMER,handleTimerTick);
            timer.start();
            mySwv = new QNXStageWebView("myBrowser");
            mySwv.stage = this.stage;
            mySwv.viewPort = new Rectangle(50,50,400,400);
            mySwv.addEventListener(WebViewEvent.DOCUMENT_LOAD_FINISHED, onLoad);
            mySwv.addEventListener(WebViewEvent.DOCUMENT_LOAD_FAILED, onFail);
            mySwv.loadURL("http://www.qnx.com/");
            mySwv.scrollBy(100,100);
            mySwv.zoomToFitWidthOnLoad = true;
            mySwv.blockPopups = true;
            mySwv.zOrder = -1;
            myProgress = new PercentageBar();
            myProgress.x = (400-myProgress.width) /2;
            myProgress.y = (500-myProgress.height) /2;
            myProgress.width = 200; 
            this.addChild(myProgress);
        }
        private function handleTimerTick(e:Event):void 
        {
            myProgress.progress = mySwv.loadProgress/100;
        }
        private function onLoad(e:WebViewEvent):void
        {
            myProgress.progress = 1;
            mySwv.zOrder = 0;
            myProgress.destroy();
            trace("completely loaded");
        }
        private function onFail(e:WebViewEvent):void
        {
            trace("The document failed to load");
        }
    }
}

 

 As you can see when I click on any link, when the page fully renders, I get the debug statements as shown below:

 

stageviewDebug.jpg

 

What version of the OS are you using? Are you using the latest production build in the market?

 

Looking forward to your reply.

Raihan Masroor
BlackBerry Development Advisor
New Contributor
Posts: 5
Registered: ‎11-03-2011
My Device: Non-blackberry user
My Carrier: non-blackberry user

Re: QNXStageWebView and self-signed certificates

Hi Raihan,

 

I forgot to mention it before, I'm creating a Flex Mobile project using Flash Builder 4.5.1 and BlackBerry Tablet OS SDK 1.1.0. I'm testing it on OS version 1.0.7.3312.

 

Following the lines of code you gave, I created a sample Flex mobile project and here is the code I'm using:

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
		xmlns:s="library://ns.adobe.com/flex/spark" actionBarVisible="false" creationComplete="view1_creationCompleteHandler(event)">
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
	
	<fx:Script>
		<![CDATA[
			import mx.events.FlexEvent;
			
			import qnx.events.WebViewEvent;
			import qnx.media.QNXStageWebView;
			
			private var mySwv:QNXStageWebView;
			private var timer:Timer = new Timer(30000); // Waiting for 30 seconds
			
			protected function labelbutton1_clickHandler(event:MouseEvent):void
			{
				mySwv = new QNXStageWebView("myBrowser");
				mySwv.stage = this.stage;
				mySwv.viewPort = new Rectangle(0,50,1024,540);
				mySwv.addEventListener(WebViewEvent.DOCUMENT_LOAD_FINISHED, onLoad);
				mySwv.addEventListener(WebViewEvent.DOCUMENT_LOAD_FAILED, onFail);
				mySwv.zoomToFitWidthOnLoad = true;
				mySwv.blockPopups = true;
				mySwv.enableJavaScript = true;
				mySwv.enablePlugins = true;
				mySwv.enableCookies = true;
				mySwv.enableCrossSiteXHR = true;
				mySwv.loadImages = true;
				mySwv.displayDefaultDialogs = true;
				mySwv.zOrder = -1;
				
				mySwv.loadURL(this.txtURL.text);
				timer.start();
			}
			
			private function onLoad(e:WebViewEvent):void
			{
				mySwv.zOrder = 0;
				timer.stop();
				
				trace("completely loaded: "+(e.currentTarget as QNXStageWebView).location);
			}
			private function onFail(e:WebViewEvent):void
			{
				trace("The document failed to load");
			}
						
			
			protected function view1_creationCompleteHandler(event:FlexEvent):void
			{
				timer.addEventListener(TimerEvent.TIMER, onTimerExpiry);
			}
			
			private function onTimerExpiry(event:TimerEvent):void
			{
				trace("Failed to load document within 30 seconds: "+this.txtURL.text);
			}
			
		]]>
	</fx:Script>
	
	<s:TextInput id="txtURL" width="960" y="8" height="40" />
	<s:Button label="GO" x="968" y="8" width="44" height="36" 
			  click="labelbutton1_clickHandler(event)"/>
	
</s:View>

 The issue that I'm facing is not when accessing http sites, but it is when I try to access sites which has untrusted/invalid certificates using https. Using the above code, I tried accessing http://google.com, https://mail.google.com, and https://startcom.com. Here are the results I see:

 

-------------------------------------------------------------------------------------------------------------

[SWF] WebViewSample.swf - 3,157,223 bytes after decompression
completely loaded: http://www.google.co.in/
completely loaded: https://mail.google.com/mail/
completely loaded: https://accounts.google.com/ServiceLogin?service=mail&passive=true&continue=https://mail.google.com/...
Failed to load document within 30 seconds: https://startcom.com

 

-------------------------------------------------------------------------------------------------------------

 

 I get Document_Load_Finished events for both http://google.com and https://mail.google.com, but do not get neither the Document_Load_Finished event nor the Document_Load_Failed event.

 

To ascertain that it is not an issue with Flex, I tried your example as it is by creating an ActionScript mobile project and I see the same result. Can you please try accessing https://startcom.com? This website seems to be using an invalid certificate. However, when I try to access the same website from the PlayBook's browser, it prompts me the certificate dialog.

 

Waiting for your reply.

 

Thanks,

Kiran

New Contributor
Posts: 5
Registered: ‎11-03-2011
My Device: Non-blackberry user
My Carrier: non-blackberry user

Re: QNXStageWebView and self-signed certificates

just a correction, I do not get neither the Document_Load_Finished event nor the Document_Load_Failed event when I try to access https://startcom.com
Retired
Posts: 172
Registered: ‎06-07-2010
My Device: BlackBerry 8520
My Carrier: Rogers

Re: QNXStageWebView and self-signed certificates

Hello Kiran,

 

Thanks for your input. Forgive my absence of a reply. I'm able to reproduce the issue you are seeing and trying to find a workaround to the situation.

 

Will reply as soon as I find an answer. Thanks for the patience.

Raihan Masroor
BlackBerry Development Advisor
Retired
Posts: 172
Registered: ‎06-07-2010
My Device: BlackBerry 8520
My Carrier: Rogers

Re: QNXStageWebView and self-signed certificates

Hello Kiran,

 

After further investigation, the dialog for the certificate which is popped up by the WebKit is done under the covers. The issue that is being seen is actually a sdk bug. The bug however has been fixed and the fix will be available in the next release of the blackberry-tablet-sdk.

 

Let me know if you have any questions and I will be glad to answer them for you. 

Raihan Masroor
BlackBerry Development Advisor
New Contributor
Posts: 5
Registered: ‎11-03-2011
My Device: Non-blackberry user
My Carrier: non-blackberry user

Re: QNXStageWebView and self-signed certificates

Hi Raihan,

 

Any idea about ETA of the new Tablet SDK with this fix?

 

Thanks,

Kiran

Retired
Posts: 172
Registered: ‎06-07-2010
My Device: BlackBerry 8520
My Carrier: Rogers

Re: QNXStageWebView and self-signed certificates

Hey Kiran,

 

 

At the moment, our release date for the next version of the tablet SDK has not yet been announced. Stay tuned to our developer blogs via http://devblog.blackberry.com/ for updates. 

 

Sorry that I wasn't able to provide more details in the answer to your question.

 

Raihan Masroor
BlackBerry Development Advisor