Java Web 应用程序和密钥库
我正在设计一个小工具(Web 界面和 Web 服务),用于使用 RSA 私钥对一些数据进行签名。该应用程序将拥有多个私钥(即针对不同类型的 blob),并且将来我们可能会弃用某些密钥(并添加新的私钥)。
问题是我应该将 KeyStore 文件存储在哪里?将其添加到 META-INF 似乎不是一个好主意,因为它会被软件更新覆盖。其他选项是存储到 /etc/myapp/keys.keystore 之类的内容或存储到 blob 列中的表中。
那么,存储密钥库的“规范”方式是什么?
I'm designing a small tool (web interface and web services), for signing some blob's of data with a private RSA key. The application will have more than one private key (ie. for different types of blob's), and in the future we might deprecate some of the keys (and add new ones).
The question is where should I store the KeyStore file? Adding it to META-INF doesn't seems like a good idea, as it would be overwritten with a software update. Other options, would be to store to something like /etc/myapp/keys.keystore or to a table in a blob column.
So, what is the "canonical" way of storing a keystore?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为没有规范的方法。也许最好的选择是将密钥库放在应用程序外部,并配置其位置(例如通过
-Dkeystore.location=/home/..
(类似于 此)。I don't think there's a canonical way. Perhaps the best option would be to have the keystore external to the application, and configure it's location (for example via
-Dkeystore.location=/home/..
(something similar to this).过去,我将密钥库存储在文件系统上,作为扩展名为
.jks
的文件。相关应用程序始终以特定用户身份运行,因此我们将该文件放入用户主目录(的子目录)中。然后我们编写了一些代码,我认为没有规范的方法可以做到这一点(尽管我可能是错的)。这种方法对于我们的用例来说效果很好。
In the past, I've stored keystores on the file system, as a file with the
.jks
extension. The app in question always runs as a particular user, so we put the file in (a subdirectory of) the user's home directory. We then had some code along the lines ofI don't think there's a canonical way to do this (though I might be wrong). This way has worked well for our use case.
我还没有尝试过这个,但看起来推荐的方法是使用 context.xml 中的环境条目。
Tomcat 文档
相关 stackoverflow 问题这里
另外,您如何描述如何实现加密听起来可能存在一些问题。阅读用户 erickson 在各种答案中的建议,了解如何正确执行此操作。首先是一个问题:Java 256 位 AES 基于密码的加密
I've not tried this, but it looks like the recommended way to do this is using environment entries in context.xml.
Tomcat docs here
Related stackoverflow question here
Also, how you are describing how you're going to implement the encryption sounds like there are potentially some problems with it. Read the user erickson's recommendations in various answers to see how to do this right. Here is a question to start with: Java 256-bit AES Password-Based Encryption