我一直在尝试使用谷歌在Xamarin.iOS上的服务账户。PCL项目不支持System.Security.Cryptography.X509Certificates,所以我需要一种不同的方式(如Bouncy Castle或PCLCrypto)来将X509Certificate加载到项目中。基本上,与Google的文档一样,提取证书的方法如下:
var certificate = new X509Certificate2(@"key.p12", "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { PlusService.Scope.PlusMe }
}.FromCertificate(certificate));问题是,在Bouncy Castle中加载证书(代码的第一行)的替代方法是什么?
发布于 2017-05-26 00:00:31
您可以将PCL项目的目标更改为.NETStandard。在这之后
System.Security.Cryptography.X509Certificates
是支持的。
您可以通过以下步骤来完成此操作:
"netstandard1.3": { "imports": "portable-net45+win8+wp8+wpa81"}对于步骤4,您必须删除所有Nuget包,并且在步骤6之后,您必须重新安装它们。
https://stackoverflow.com/questions/37820804
复制相似问题