本文整理汇总了C#中System.Security.Cryptography.X509Certificates.X509Certificate2.ExportCspBlob方法的典型用法代码示例。如果您正苦于以下问题:C# X509Certificate2.ExportCspBlob方法的具体用法?C# X509Certificate2.ExportCspBlob怎么用?C# X509Certificate2.ExportCspBlob使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Cryptography.X509Certificates.X509Certificate2
的用法示例。
在下文中一共展示了X509Certificate2.ExportCspBlob方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Person person = CurrentPerson;
if (person != null)
{
pnlPrivatePrayer.Visible = true;
string name = person.FullName.Replace(" ", "");
string guid = person.Guid.ToString().Replace("-", "");
string uid = name + guid;
hdnDisplayName.Value = person.FullName;
hdnPerson.Value = person.Id.ToString();
hdnRoom.Value = name + guid;
hdnEmail.Value = person.Email;
hdnPhoto.Value = person.PhotoUrl;
hdnDate.Value = DateTime.Now.Date.ToShortDateString().Replace("/", "");
var baseDate = new DateTime(1970, 1, 1);
var startDate = (DateTime.Now.ToUniversalTime() - baseDate).TotalSeconds;
var endDate = ((DateTime.Now.AddHours(1)).ToUniversalTime() - baseDate).TotalSeconds;
var payload = new Dictionary<string, object>()
{
{"aud", ConfigurationManager.AppSettings["FirebaseAud"].ToString() },
{"iat", Math.Truncate(startDate) },
{"exp", Math.Truncate(endDate) },
{"iss", ConfigurationManager.AppSettings["FirebaseIss"].ToString() },
{"sub", ConfigurationManager.AppSettings["FirebaseIss"].ToString() },
{"user_id", uid },
{"scope", "https://www.googleapis.com/auth/identitytoolkit" }
};
var header = new Dictionary<string, object>()
{
{"alg", "RS256" },
{"kid", ConfigurationManager.AppSettings["FirebaseKid"].ToString() },
{"typ", "JWT" }
};
string filePath = Server.MapPath(ConfigurationManager.AppSettings["CertFile"]);
RSACryptoServiceProvider cert = new X509Certificate2(filePath, ConfigurationManager.AppSettings["CertPassword"], X509KeyStorageFlags.Exportable).PrivateKey as RSACryptoServiceProvider;
System.Security.Cryptography.RSACryptoServiceProvider rsa = new System.Security.Cryptography.RSACryptoServiceProvider();
rsa.ImportCspBlob(cert.ExportCspBlob(true));
string token = Jose.JWT.Encode(payload, rsa, Jose.JwsAlgorithm.RS256, extraHeaders: header);
hdnToken.Value = token;
}
else
{
// add in logic for person not logged in
}
}