c# - 在数据库中存储 RsaSecurityKey

标签 c# postgresql asp.net-core rsa identityserver4

如何存储 RsaSecurityKey https://msdn.microsoft.com/en-us/library/system.identitymodel.tokens.rsasecuritykey(v=vs.110).aspx 类的对象在关系数据库(如 Postgres)中?

我必须创建 RsaSecurityKey(第一次)并将 key 存储在数据库中,并在 Identity Server(使用 IdentityServer4 库)中使用它来签署 Jwt token 。

最佳答案

我不确定您是否能够按原样将该类型的对象存储到数据库中,因为它们不可序列化 - 例如:如果您尝试使用 .NET BinaryFormatter 将其转换为字节数组,它将失败并出现 SerializationException

谷歌搜索显示还有其他人也遇到了这个问题,例如在 AzureAD 项目中:

https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/591

如果您关注the pull request在该问题中,有源代码似乎可以满足您的要求。 注意:如果您打算使用该许可证,请确保您了解该许可证。

关于c# - 在数据库中存储 RsaSecurityKey,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48097762/

相关文章:

c# - 使用 NUnit 按顺序运行 TestFixtures

Postgresql json 类查询

sql - 无法重置分区组(特别是窗口函数和 PostgreSQL)

javascript - 在 signalR 核心启动时设置自定义 ID

asp.net-web-api - 为 ASP.NET Core Controller 自动生成 TypeScript 客户端代码

c# - 如何在 Web API 中使用 AutoFac 在运行时解析服务?

c# - 无法执行 not-in

c# - 10 秒后从控制台 (C#) 打开网页

ruby-on-rails - 如何发布到 Rails Controller 中的连接表

c# - 构建 : error MSB4062 Microsoft. Build.Tasks.ResolveComReference 时出现 .NET Core 错误