仅存储私钥在密钥库中,并使用Java读取它

发布于 2025-01-30 08:08:01 字数 453 浏览 1 评论 0原文

我想将一个私钥存储在Java密钥库中。我的文件看起来像

-----BEGIN PRIVATE KEY-----
actual key
-----END PRIVATE KEY-----

我通过谷歌搜索获得的所有示例都涉及存储证书。我没有证书,也不需要它。

如何通过命令行在Linux计算机上仅存储一个私钥? (Java中似乎有一些示例,但是Sysadmin将在将部署应用程序的所有机器中添加它,因此需要命令行方法)

我需要从Java应用程序中读取私钥,我希望类似的东西

  final Key key = (PrivateKey) keystore.getKey(alias, password.toCharArray());

会起作用,但无法对其进行测试,因为我首先无法存储私钥。

我需要从我的Java应用程序中读取该键

I want to store a private key in a java keystore. My file looks like

-----BEGIN PRIVATE KEY-----
actual key
-----END PRIVATE KEY-----

All examples I get by googling involve storing a certificate as well. I do not have a certificate and I do not need it.

How do I store only a private key on a linux machine via the command line? (There seem to be some examples in java, but a sysadmin would be doing adding it in all machines where the application will be deployed, so a command line method is needed)

I need to read the private key from a java application, I hope that something similar to

  final Key key = (PrivateKey) keystore.getKey(alias, password.toCharArray());

will work, but haven't been able to test it as I haven't been able to store a private key in the first place.

I would need to read that key from my java application

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文