c# - Xamarin/Mono Mac - AppStore 构建中的握手失败

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

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

唯一的问题是 Web 请求似乎失败了,因为它们甚至没有被触发。

以下代码片段摘自 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);
            }

但是,当我切换到 AppStore 构建时,使用沙箱和网络 IO 授权,请求永远不会发送出去,由 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 调用来执行操作,第一个操作是登录。对于调试和发布,登录工作正常,因为调用已完成。再一次,AppStore 版本甚至没有尝试建立联系。

证书有效,并且 CA 安装在我的钥匙串(keychain)中。

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

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 实例。

干杯。

最佳答案

检查您的应用程序是如何打包的。

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

mtouch 希望您相信。

链接器行为的默认选项是链接所有程序集。这将使用 mtouch 来尝试通过修改用户代码 使应用程序尽可能小。这可以而且将会破坏以 mtouch 无法检测的方式使用功能的代码(例如网络服务、反射或序列化)。

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

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

Xamarin Studio - 项目选项窗口

Linker behaviour in a particular project

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

更多信息

Xamarin Guides - Linker with iOS

关于c# - Xamarin/Mono Mac - AppStore 构建中的握手失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22706157/

相关文章:

ssl - 如何在 Powershell 中使用客户端证书创建 TCP 客户端连接

c++ - 在多线程上下文中卸载 Mono 域

.net - 我如何使用单声道 objective-c #/.net 4 进行编译

c# - 是否可以在 C# 项目中使用 XDT?

javascript - axios 和 jQuery 帖子格式

SSL 对所有主机都失败。 (SSL证书问题: self signed certificate in certificate chain)

css - IE7 不通过 SSL 缓存 CSS 图像

c# - 为什么三元运算符不根据要查找的值找到转换类型?

c# - 桌面上方的 float 图标

c# - mkbundle组合DLL在其他项目中引用时导致Invalid Metadata异常