Xamarin 跨平台证书固定 [英] Xamarin Cross Platform Certificate pinning
问题描述
我正在使用 Xamarin 设计一个应用程序,我想通过使用证书固定来提高我们的安全性.但我找不到办法做到这一点.我可以使用android的本机方法来做到这一点,但我想知道是否有跨平台的解决方案,甚至是windows phone的解决方案.
I am designing an application using Xamarin and I want to boost our security by using certificate pinning. But I cannot find a way to do it. I can use the native approach for android to do it, but I want to know if there is a cross-platform solution to this, or even a solution for windows phone at all.
推荐答案
在 Android 和 iOS 上,您可以通过 ServicePointManager.ServerCertificateValidationCallback
使用标准的 .NET 方式.
On Android and iOS you can use the standard .NET way with ServicePointManager.ServerCertificateValidationCallback
.
在Windows Phone 8上可以使用StreamSocket
,连接后调用UpgradeToSslAsync
,然后读取证书详情.
On Windows Phone 8 you can use StreamSocket
, call UpgradeToSslAsync
after connecting and then read the certificate details.
在 Windows Phone 8.1 上,您还可以使用<代码>var uri = new Uri("https://someuri.com/");var httpClient = new HttpClient();var httpResponseMessage = 等待 httpClient.GetAsync(uri);var 证书 = httpResponseMessage.RequestMessage.TransportInformation.ServerCertificate;
On Windows Phone 8.1 you may also use
var uri = new Uri("https://someuri.com/");
var httpClient = new HttpClient();
var httpResponseMessage = await httpClient.GetAsync(uri);
var certificate = httpResponseMessage.RequestMessage.TransportInformation.ServerCertificate;
所以不是跨平台解决方案...
So not a cross platform solution...
SecureBlackbox 可能有助于跨平台解决方案,但我之前只在 Windows Phone 7.xa 中使用过它.
SecureBlackbox might be able to help with a cross platform solution, but I've only used it with Windows Phone 7.x a while ago.
这篇关于Xamarin 跨平台证书固定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!