Xamarin Forms - Salesforce - TLS 1.1或TLS 1.2。 Android的POST API调用错误

时间:2016-09-19 12:58:02

标签: xamarin.android xamarin.forms dotnet-httpclient

我们正试图从我们的Xamarin Forms项目调用Salesforce restful API。这些调用在iOS应用程序方面运行良好,但在Android方面失败。

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并且它有效。现在chekcing为Android而不工作。对于Windows,我们不检查。

请帮助。

1 个答案:

答案 0 :(得分: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();
}
相关问题