2014-03-28 16 views
3

我有一個應用程序現在需要部署到應用程序商店,因爲Gatekeeper它正在慢慢變得不可避免。Xamarin/Mono Mac - AppStore構建中的握手失敗

唯一的問題是,網絡請求似乎失敗,因爲他們甚至沒有被解僱。

以下代碼片段已從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權利,請求永遠不會被髮送出去,在非SSL解密模式由Charles驗證。以下內容將從控制檯中吐出來;

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安裝在我的鑰匙串中。導致這一點,我在代碼(在調試中),例如一些例外;

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

乾杯。

+2

我也有過類似的問題,當我用'http',而不是'https',但我想,如果你需要'SSL'這裏一切正常,這並未不解決你的問題 – eggy

回答

1

檢查應用程序的打包方式。

默認情況下,在構建項目時(無論是在Xamarin Studio還是Visual Studio中),它都會調用一個名爲mtouch的工具,該工具包含一個用於託管代碼的鏈接器。該工具用於從應用程序未使用的類庫中移除功能。

左右mtouch想讓你相信。

鏈接器行爲的默認選項是Link all assembiles。這將使用mtouch嘗試通過修改用戶代碼使應用程序儘可能小。這可以並且將破壞使用功能的代碼,其方式是mtouch無法檢測(例如web服務,反射或序列化)。

我使用的解決方法是禁用鏈接。通過將鏈接器行爲更改爲Don't Link,這將確保不會修改任何程序集。

您可以找到菜單右鍵點擊相關的項目要做到這一點,並選擇Options

Xamarin工作室 - 項目選項窗口

Linker behaviour in a particular project

試着改變連接器行爲到Don't Link(如上所示)並重建。

更多信息

Xamarin Guides - Linker with iOS