Example #1
0
        public RsaSecurityKey GetPrivateRsaSecurityKey()
        {
            var privateRsa    = RSA.Create();
            var privateKeyXml = File.ReadAllText(_settings.RsaPrivateKeyXml);

            Xmlhelper.FromXmlString(privateRsa, privateKeyXml);
            var priavteRsaSecurityKey = new RsaSecurityKey(privateRsa);

            return(priavteRsaSecurityKey);
        }
Example #2
0
        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);
            }
        }