2016-09-19 78 views
1

我们正试图从我们的Xamarin Forms项目调用Salesforce restful API。这些调用在iOS应用程序方面工作正常,但Android失败。Xamarin表单 - Salesforce - TLS 1.1或TLS 1.2。针对Android的POST API调用错误

HttpClient authClient = new HttpClient(); 
message = await authClient.PostAsync("url", content); 
string responseString = await message.Content.ReadAsStringAsync(); 

我们在Android的“responseString”变量中收到以下响应。

<tr><td width="100%" height="100%"><div class="content"> 
<h1>**Stronger security is required**</h1><div class="simple"> 
<p>**To access this website, update your web browser or upgrade your operating system to support TLS 1.1 or TLS 1.2.**</p> 
<p>For more information, see 
<a href="https://help.salesforce.com/HTViewSolution?id=000221207&amp;language=en_US" target="_blank">Salesforce disabling TLS 1.0</a>. 
</p> 
</div></div></td></tr> 
</table></body> 
</html> 

我们需要找到一个应该支持iOS,Android和Win 10应用程序的解决方案。我们检查了iOS,它工作。现在为了Android而加入并且不工作。对于Windows,我们不检查。

请帮忙。

回答

0

我还没有亲自去过这个问题,但你可能会给ModernHttpClient一枪。安装该库允许您将NativeMessageHandler传入您的HttpClient。这将使用Android上的本机实现,这将允许使用Xamarin Forms实现不能实现的额外安全功能。

如果可能,您还应该将Xamarin Forms库更新为最新版本。

您的代码将成为(我还添加了using,因为它是很好的做法):

using(HttpClient authClient = new HttpClient(new NativeMessageHandler())) { 
    message = await authClient.PostAsync("url", content); 
    string responseString = await message.Content.ReadAsStringAsync(); 
}