![](/img/trans.png)
[英]C# How to S/Mime in Asp.net 5 with Bouncy Castle instead of x509certificate2
[英]How to add X.509 v.3 google certificate to project with Bouncy Castle in c#
我一直在嘗試在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中加載證書(代碼的第一行)的替代方法是什么?
您可以將PCL項目的目標更改為.NETStandard。 在這之后,
System.Security.Cryptography.X509Certificates
支持。
您可以按照以下步驟操作:
"netstandard1.3": { "imports": "portable-net45+win8+wp8+wpa81"}
對於步驟4,您必須刪除所有的Nuget軟件包,在步驟6之后,必須重新安裝它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.