如何存储 Java KeyStore 密码?

发布于 2024-09-05 14:16:43 字数 163 浏览 1 评论 0原文

在我的 Web 应用程序中,我访问存储在 Java KeyStore 中的私钥。我想知道存储 KeyStore 和私钥密码的最佳/推荐方法是什么。

我考虑过使用属性文件,但在生产环境中使用它似乎不太安全(将密码存储在纯文本文件中)。此外,我不愿意在代码中对密码进行硬编码。

谢谢。

In my web application I access a private key that is stored in a Java KeyStore. I would like to know what is the best/recommended way to store the password for the KeyStore and private key.

I've considered using a properties file but that does not seem very secure for use in a production environment (storing password in a plain text file). Also, hard-coding the password in my code is not an option I'm willing to entertain.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

趁微风不噪 2024-09-12 14:16:43

这是一个棘手的引导问题。一些选项:

  • 让您的应用程序提示用户解锁密钥库(不是很友好,但可能)

  • 将密码存储在所有者只读文件 (0400 ) 并使用它来解锁密钥库。攻击者必须闯入您的服务器才能读取该文件。这似乎是最广泛使用的技术
  • 使用 HSM
  • 使用 Hashicorp Vault 之类的技术(但它也存在引导问题)。

This is a tricky bootstrapping problem. Some options:

  • Have your app prompt the user to unlock the keystore (not very friendly, but possible)

  • Store the password in an owner read only file (0400 ) and use that to unlock the keystore. The attacker has to break into your server to read the file. This seems to be the most widely used technique
  • Use an HSM
  • Using something like Hashicorp Vault (but it also has the bootstrapping issue as well).
白芷 2024-09-12 14:16:43

您可以使用属性文件,正如您提到的那样,只需对密码进行哈希处理以获得额外的安全性,盐对密码进行哈希处理。这解决了必须以纯文本形式保存密码的问题。然后,您可以使用 MD5 或 SHA1 密码对其进行哈希处理,具体取决于个人选择。

You could use a properties file as you mentions just hash the password for extra security salt hash the password. This gets round the issue of having to keep a password in plain text. You can then either use MD5 or SHA1 password to hash it, personal choice.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文