我一直在尝试在Xamarin.iOS上使用Google的服务帐户。 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中加载证书(代码的第一行)的替代方法是什么?
答案 0 :(得分:0)
您可以将PCL项目的目标更改为.NETStandard。在此之后,
支持System.Security.Cryptography.X509Certificates
。
您可以按照以下步骤执行此操作:
"netstandard1.3": { "imports": "portable-net45+win8+wp8+wpa81"}
对于第4步,您必须删除所有Nuget包,在步骤6之后,您必须重新安装它们。