簡體   English   中英

我的AIR移動應用程序忽略了Android證書存儲區

[英]Android certificate store is being ignored by my AIR mobile application

我正在為Android開發AIR(Flex)移動應用程序,它需要使用SSL或TSL與http服務器進行通信。 我使用Firefox獲得了CA證書鏈(也已使用其他工具進行了檢查),並獲得了以下鏈:

在此處輸入圖片說明

抓到的一個是我公司的SSL / TSL服務器。 出於安全原因,我不希望發布其地址。 因此,在找出了我需要哪些證書(僅兩個)之后,我在Android平板電腦上搜索了安裝了哪些證書。 如下圖所示,系統上已經安裝了根證書“ VeriSign 3類公共主要證書頒發機構-G5”:

在此處輸入圖片說明

我需要下載的唯一一個文件是“ VeriSign 3類安全服務器CA-G3”,我已經下載了:

在此處輸入圖片說明

現在,我嘗試使用兩種不同的瀏覽器進入HTTP服務器,並且不再需要接受任何證書。 當AIR進入現場時,問題就來了。 我嘗試了兩種使用HTTPService和SecureSocket與服務器通信的方法。 對於第一個,我使用以下代碼:

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        title="HomeView">

    <fx:Declarations>
        <s:HTTPService id="bookingservice" 
                       resultFormat="text"
                       url="https://www.myserver.com/"
                       result="bookingservice_resultHandler(event)"
                       fault="bookingservice_faultHandler(event)"/>
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;

            protected function button1_clickHandler(event:MouseEvent):void
            {
                resultado.text = "llamando...";
                bookingservice.send();
            }
            protected function bookingservice_resultHandler(event:ResultEvent):void
            {
                resultado.text = event.result as String;
            }

            protected function bookingservice_faultHandler(event:FaultEvent):void
            {
                resultado.text = "satus code: " + event.statusCode + " mensaje: " + event.message.toString();
            }
        ]]>
    </fx:Script>

    <s:Button top="10" right="10" click="button1_clickHandler(event)" label="Extra" />

    <s:TextArea id="resultado" 
                width="80%" height="80%" 
                horizontalCenter="0" verticalCenter="0" />

</s:View>

這種難以置信的簡單方法以一個消息框結尾,要求用戶接受未驗證的服務器,即使其所有鏈證書都已安裝在Android的系統證書存儲中。 對於第二種方法,我使用以下代碼:

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        title="HomeView">

    <fx:Script>
        <![CDATA[

            private var secureSocket:SecureSocket = new SecureSocket;

            protected function button1_clickHandler(event:MouseEvent):void
            {
                secureSocket.addEventListener( Event.CONNECT, onConnect )
                secureSocket.addEventListener( IOErrorEvent.IO_ERROR, onError );

                resultado.text = "llamando...";
                try
                {
                    secureSocket.connect( "https://www.myserver.com/",443);
                }
                catch ( error:Error )
                {
                    trace ( error.toString() );
                }

                resultado.text = "llamando...";
            }
            private function onConnect( event:Event ):void
            {
                resultado.text =  "Connected.";
            }

            private function onError( error:IOErrorEvent ):void
            {
                resultado.text = error.text + ", Server Certificate Status: " + secureSocket.serverCertificateStatus;
            }

        ]]>
    </fx:Script>

    <s:Button top="10" right="10" click="button1_clickHandler(event)" label="Extra" />

    <s:TextArea id="resultado" 
                width="80%" height="80%" 
                horizontalCenter="0" verticalCenter="0" />

</s:View>

對於最后一種方法,我什至沒有收到要求證書授權的消息框,只得到了一條錯誤消息:“錯誤#2031:套接字錯誤。 URL: https : //www.myserver.com/ ,服務器證書狀態:無效”。 我想知道為什么AIR(Flex)移動運行時不考慮已安裝在Android證書存儲區中的證書,而是仍在請求用戶授權,甚至更糟的是,給出錯誤並說服務器證書無效。 有人知道為什么會這樣嗎? 我想念什么嗎?

每一點幫助將不勝感激。

不是真正的答案,但是對於SecureSocket-

您可以使用addBinaryChainBuildingCertificate()方法以編程方式添加自己的證書

只需更改

secureSocket.connect(“ https://www.myserver.com/”,443 );

secureSocket.connect(“ www.myserver.com”,443);

(假設“ www.myserver.com”是證書中命名的域)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM