mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 10:40:29 +01:00
ef9c2e8af1
* Part 1: OpenIddict - Minor Changes & Config prep * Part 1: OpenIddict - Minor Changes & Config prep * Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies * pr changes * pr changes * fix merge * pr fixes * remove config for openid -- no need for it for now * fix compile * fix compile #2 * remove extra ns using * Update Startup.cs * compile * adjust settings a bit * remove duplicate * remove external login provider placeholder html * remove unused directives * regenerate db snapshot model * Remove dynamic policy
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using System.IO;
|
|
using System.Security.Cryptography;
|
|
using BTCPayServer.Configuration;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using NETCore.Encrypt.Extensions.Internal;
|
|
|
|
namespace BTCPayServer
|
|
{
|
|
public static class OpenIddictExtensions
|
|
{
|
|
public static OpenIddictServerBuilder ConfigureSigningKey(this OpenIddictServerBuilder builder,
|
|
IConfiguration configuration)
|
|
{
|
|
|
|
var file = Path.Combine(configuration.GetDataDir(), "rsaparams");
|
|
|
|
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(2048);
|
|
RsaSecurityKey key = null;
|
|
|
|
if (File.Exists(file))
|
|
{
|
|
RSA.FromXmlString2( File.ReadAllText(file));
|
|
}
|
|
else
|
|
{
|
|
var contents = RSA.ToXmlString2(true);
|
|
File.WriteAllText(file,contents );
|
|
}
|
|
|
|
RSAParameters KeyParam = RSA.ExportParameters(true);
|
|
key = new RsaSecurityKey(KeyParam);
|
|
return builder.AddSigningKey(key);
|
|
}
|
|
}
|
|
}
|