我的空中移动应用程序忽略了Android证书存储
我正在为Android开发一个AIR(Flex)移动应用程序,它需要使用SSL或TSL与http服务器通信。我使用Firefox获得CA证书链(还使用其他工具进行了检查),并获得以下链: 划伤的是我公司的SSL/TSL服务器。出于安全原因,我不想邮寄它的地址。 因此,在找到我需要的证书(链中只有两个)后,我在安卓平板电脑上搜索安装了哪些证书。如下图所示,根证书“VeriSign Class 3 Public Primary Certification Authority-G5”已安装在系统上: 我唯一需要下载的是“VeriSign 3级安全服务器CA-G3”,我已经下载了: 现在,我尝试使用两种不同的浏览器进入HTTP服务器,不再需要接受任何证书。当空气进入现场时,问题就出现了。我尝试了两种与服务器通信的方法,使用HTTPService和SecureSocket。 对于第一个,我使用以下代码:我的空中移动应用程序忽略了Android证书存储,android,actionscript-3,air,ssl-certificate,flex-mobile,Android,Actionscript 3,Air,Ssl Certificate,Flex Mobile,我正在为Android开发一个AIR(Flex)移动应用程序,它需要使用SSL或TSL与http服务器通信。我使用Firefox获得CA证书链(还使用其他工具进行了检查),并获得以下链: 划伤的是我公司的SSL/TSL服务器。出于安全原因,我不想邮寄它的地址。 因此,在找到我需要的证书(链中只有两个)后,我在安卓平板电脑上搜索安装了哪些证书。如下图所示,根证书“VeriSign Class 3 Public Primary Certification Authority-G5”已安装在系统上:
<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>
<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>
这种难以置信的简单方法以一个消息框结束,该消息框要求用户接受未经验证的服务器,即使其所有链证书都安装在Android的系统证书存储中。
对于第二种方法,我使用以下代码:
<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>
<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>
对于最后一种方法,我甚至没有收到请求证书授权的消息框,我只收到一个错误,上面写着:“error#2031:Socket error.URL:,服务器证书状态:invalid”。
我想知道为什么AIR(Flex)移动运行时不考虑Android证书存储上已经安装的证书,它仍然要求用户授权,甚至最糟糕的是,给出错误并说服务器证书无效。有人知道为什么会这样吗?我错过什么了吗
每一点帮助都将被感激。不是真正的答案,而是- 您可以使用以编程方式添加自己的证书 addBinaryChainBuildingCertificate()方法 简单地改变 secureSocket.connect(“,443) 到 secureSocket.connect(“www.myserver.com”,443)
(假设“www.myserver.com”是证书中指定的域)而不是
www.myserver.com
您是否也尝试过myserver.com
?@AlexanderFarber,www.myserver.com
实际上只是一个例子,域是something.myserver.com
。类的文档没有解释如何使用addBinaryChainBuildingCertificate()
。你知道如何使用ir吗?我下载了三个证书中的每一个,将它们转换成DER格式(Firefox将它们导出为PEM)使用addBinaryChainBuildingCertificate()
,将所有三个证书都添加到套接字中,使用该方法我甚至没有收到任何错误(如果证书格式不正确,你会这样做),还是同样的错误:“error#2031:Socket error.URL:https://www.myserver.com/,服务器证书状态:无效“
。你还有什么线索吗?