【问题标题】:How to safely store API credentials in a SQL Server database?如何在 SQL Server 数据库中安全地存储 API 凭据?
【发布时间】:2016-05-11 03:21:44
【问题描述】:

在我的 Windows 服务中,我需要能够检索存储在同一网络上的 SQL Server 2012 数据库中的第三方 REST API 的凭据。我的每个客户都可能分配有不同的 API 凭证。例如:

Customer Name | API ID | API Password In Plain Text
-----------------------------------------------------
Customer 1      1234     somepassword
Customer 2      1234     somepassword
Customer 3      5678     anotherpassword

在此服务的第一次迭代中,所有客户都使用相同的 API 凭据,并在 Windows 服务的 app.config 中使用 SectionInformation.ProtectSection 对其进行加密。

我是否只使用 .NET 框架提供的一种加密/解密方法并将该值存储在数据库中?例如,此处提供的解决方案之一:Encrypting & Decrypting a String in C#?我可以考虑任何建议或其他解决方案吗?

【问题讨论】:

标签: c# sql-server cryptography


【解决方案1】:

根据@SyntaxGoonoo 的建议,我计划使用数据保护API (DAPI) 提供的ProtectedData Class。我将设置DataProtectionScope 作为与 Windows 服务关联的 CurrentUser 运行,以解密来自 SQL 数据库的凭据。我可能不得不创建另一个应用程序来加密凭据并将其存储在数据库中(使用相同的用户上下文)。

这里有一些额外的资源:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-24
    • 1970-01-01
    相关资源
    最近更新 更多