Xamarin跨平台证书固定 [英] Xamarin Cross Platform Certificate pinning

查看:97
本文介绍了Xamarin跨平台证书固定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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上,您可以将标准.NET方式与ServicePointManager.ServerCertificateValidationCallback结合使用.

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 = await httpClient.GetAsync(uri); var certificate = 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆