将私钥存储在 ServletContext 中

发布于 2024-12-18 17:11:30 字数 257 浏览 5 评论 0原文

我想听听您的意见。我正在开发一个 Servlet,它必须签署发送到端点的请求。

为了避免从服务器的密钥库文件中读取、加载它并获取私钥,我在实现 ServletContextListener 的侦听器中完成所有这些操作。这样,仅当 servlet 初始化(部署)时才会执行此操作。

获得私钥后,我将其存储在应用程序的 ServletContext 中。您认为这是一个好的设计决策吗?

提前致谢。

I would like your opinion. I am developing a Servlet that has to sign the requests that it sends to an endpoint.

In order to avoid read from file the server's keystore, load it and get the private key, I am doing all of that in a listener that implements ServletContextListener. In this way this is done only when the servlet is initialised (deployed).

Once I get the private key I am storing it in the application's ServletContext. Do you think that is a good design decision?

Thanks in advance.

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

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

发布评论

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

评论(1

葮薆情 2024-12-25 17:11:30

无论您选择哪种解决方案,您有时都会在内存中拥有私钥。因此任何能够访问内存的破解者都可以找到一种方法来获取这个私钥。对我来说,加载一次并在启动时将其存储在内存中似乎是一个很好的解决方案。只需确保服务器不易被恶意人员访问即可。

Whatever solution you choose, you'll have the private key in memory at some time. So any cracker having access to the memory could find a way to get this private key. Loading it once and storing it in memory at startup looks like a good solution to me. Just make sure that the server is not easily accessible to malicious persons.

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