[英]How to add X.509 v.3 google certificate to project with Bouncy Castle in c#
I have been trying to use Google's service account on Xamarin.iOS. 我一直在尝试在Xamarin.iOS上使用Google的服务帐户。 System.Security.Cryptography.X509Certificates is not supported for PCL projects so i need a different way(like Bouncy Castle or PCLCrypto) to load X509Certificate into the project.
PCL项目不支持System.Security.Cryptography.X509Certificates,因此我需要以其他方式(例如Bouncy Castle或PCLCrypto)将X509Certificate加载到项目中。 Basically, as in the Google's document, the way of extracting the certificate is as following:
基本上,就像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));
The question is that, what is the alternative way of loading certificate(the first line of the code) in Bouncy Castle ? 问题是,在Bouncy Castle中加载证书(代码的第一行)的替代方法是什么?
You can change the Target of your PCL project to .NETStandard. 您可以将PCL项目的目标更改为.NETStandard。 After this,
在这之后,
System.Security.Cryptography.X509Certificates
System.Security.Cryptography.X509Certificates
is supported. 支持。
You can do it with the following steps: 您可以按照以下步骤操作:
"netstandard1.3": { "imports": "portable-net45+win8+wp8+wpa81"}
"netstandard1.3": { "imports": "portable-net45+win8+wp8+wpa81"}
For step 4 you must remove all your Nuget packages and after step 6 you must reinstall their. 对于步骤4,您必须删除所有的Nuget软件包,在步骤6之后,必须重新安装它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.