コード例 #1
0
 private void InitializeRsa()
 {
     using (RSA publicRsa = RSA.Create())
     {
         var publicKeyXml = File.ReadAllText(_settings.RsaPublicKeyXML);
         publicRsa.ConvertFromXmlString(publicKeyXml);
         _issuerSigningKey = new RsaSecurityKey(publicRsa);
     }
     if (string.IsNullOrWhiteSpace(_settings.RsaPrivateKeyXML))
     {
         return;
     }
     using (RSA privateRsa = RSA.Create())
     {
         var privateKeyXml = File.ReadAllText(_settings.RsaPrivateKeyXML);
         privateRsa.ConvertFromXmlString(privateKeyXml);
         var privateKey = new RsaSecurityKey(privateRsa);
         _signingCredentials = new SigningCredentials(privateKey, SecurityAlgorithms.RsaSha256);
     }
 }