gpt4 book ai didi

c# - 在数据库中存储一个 RsaSecurityKey

转载 作者:行者123 更新时间:2023-11-29 12:35:29 25 4
gpt4 key购买 nike

如何存储 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com