public RsaSecurityKey GetPrivateRsaSecurityKey() { var privateRsa = RSA.Create(); var privateKeyXml = File.ReadAllText(_settings.RsaPrivateKeyXml); Xmlhelper.FromXmlString(privateRsa, privateKeyXml); var priavteRsaSecurityKey = new RsaSecurityKey(privateRsa); return(priavteRsaSecurityKey); }
private void InitializeRsa() { using (var publicRsa = RSA.Create()) { var publicKeyXml = File.ReadAllText($@"{Directory.GetCurrentDirectory()}/Keys/{_settings.RsaPublicKeyXml}"); Xmlhelper.FromXmlString(publicRsa, publicKeyXml); _issuerSigningKey = new RsaSecurityKey(publicRsa); } if (string.IsNullOrWhiteSpace(_settings.RsaPrivateKeyXml)) { return; } using (RSA privateRsa = RSA.Create()) { var privateKeyXml = File.ReadAllText($@"{Directory.GetCurrentDirectory()}/Keys/{_settings.RsaPrivateKeyXml}"); Xmlhelper.FromXmlString(privateRsa, privateKeyXml); var privateKey = new RsaSecurityKey(privateRsa); _signingCredentials = new SigningCredentials(privateKey, SecurityAlgorithms.RsaSha256); } }