Xamarin / Mono Mac - AppStore版本中的握手失败

时间:2014-03-28 06:56:24

标签: c# ssl mono ssl-certificate xamarin.mac

我有一个应用程序现在需要部署到应用程序商店,因为Gatekeeper会逐渐变得不可避免。

唯一的问题是网络请求似乎失败了,因为他们甚至没有被解雇。

以下代码片段已从Xamarin Bugzilla文章中提取,并在为Release和Debug构建时成功;

            try
            {
                WebClient test = new WebClient();
                Console.WriteLine("Testing SSL GET...");
                string testresponse = test.DownloadString(checkFileUrl);
                Console.WriteLine("testresponse = " + testresponse);
            } catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.InnerException.Message);
            }

但是,当我转向使用沙盒和网络IO权利的AppStore版本时,请求永远不会被发送出去,正如Charles在非SSL解密模式下验证的那样。以下内容从控制台中吐出;

Testing SSL GET...
Error getting response stream (Write: The authentication or decryption has failed.): SendFailure
The authentication or decryption has failed.

这似乎是问题,因为我们使用对IIS服务进行的SOAP调用来执行操作,第一个是登录。对于Debug和Release,登录工作正常,因为调用已完成。 AppStore版本再次尝试联系。

证书有效,并且我的钥匙串中安装了CA.

在此之前,我在代码(在Debug中)中遇到了一些异常,例如;

System.Exception..ctor (message="invalid encoding specification.") in /private/tmp/source/bockbuild-mono-3.2.6/profiles/mono-mac-xamarin/build-root/mono-3.2.6/mcs/class/corlib/System/Exception.cs:81

System.Exception..ctor (message="Store Root doesn't exists.") in /private/tmp/source/bockbuild-mono-3.2.6/profiles/mono-mac-xamarin/build-root/mono-3.2.6/mcs/class/corlib/System/Exception.cs:81

System.Exception..ctor (message="Store CA doesn't exists.") in /private/tmp/source/bockbuild-mono-3.2.6/profiles/mono-mac-xamarin/build-root/mono-3.2.6/mcs/class/corlib/System/Exception.cs:81

仍然让我相信这是一个证书问题。测试URL是S3链接,登录服务器是具有有效证书的EC2实例。

干杯。

1 个答案:

答案 0 :(得分:1)

检查您的应用程序的打包方式。

默认情况下,在构建项目时(在Xamarin Studio或Visual Studio中),它将调用名为mtouch的工具,其中包含托管代码的链接器。此工具用于从应用程序未使用的类库中删除功能。

或者mtouch希望你相信。

链接器行为的默认选项是Link all assembiles。这将使用mtouch尝试通过修改用户代码使应用程序尽可能小。这会破坏以mtouch无法检测到的方式使用功能的代码(例如Web服务,反射或序列化)。

我使用的解决方法是禁用链接。通过将链接器行为更改为Don't Link,这将确保不修改任何程序集。

您可以通过右键单击相关项目并选择Options来找到要执行此操作的菜单:

Xamarin Studio - 项目选项窗口

Linker behaviour in a particular project

尝试将链接器行为更改为Don't Link(如上所示)并重建。

更多信息

Xamarin Guides - Linker with iOS