Hashicorp Vault:写入秘密文件然后再次读取?

发布于 2025-01-19 10:08:12 字数 446 浏览 4 评论 0原文

我们需要将Java密钥库文件存储在Hashicorp Vault中。我能够用命令像以下命令一样编写文件:

vault write -address ${VAULT_ADDR} ${SECRET_PATH} [email protected]

它运行良好,我收到了一条成功的消息。我也能够在该路径上列出凭据,并看到它是编写的。但是,如何作为Java密钥库文件恢复值? 保险库读取命令似乎仅输出yaml或json。 JSON文件中的值似乎不是基本64编码。我该如何使其输出原始二进制值,以便可以将其读取为Java密钥库?

We have a need to store a Java KeyStore file in Hashicorp Vault. I was able to write the file just fine with a command something like:

vault write -address ${VAULT_ADDR} ${SECRET_PATH} [email protected]

It worked fine, and I got a success message. I'm also able to list the credentials at that path and see that it was written. However, how do I get the value back out as a Java Keystore file? The vault read command seems to output yaml or JSON only. The value in the JSON file does not seem to be base-64 encoded. How do I get it to output the raw binary value so I can read it as a Java KeyStore?

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

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

发布评论

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

评论(1

我是有多爱你 2025-01-26 10:08:12

您的密钥库是二进制格式...可能存在编码问题。请尝试以下操作:

vault write -address {$VAULT_ADDR} ${SECRET_PATH} keystore=$(openssl base64 -A -in myKeys.keystore)

然后使用“但是 a Java 密钥库已加密...”取回它

vault read -address {$VAULT_ADDR} --field keystore ${SECRET_PATH} | openssl base64 -d -A > myKeys.keystore

... 为什么不使用 Vautl 进行密码管理?完美的用例:

  1. 使用 Vault 生成一个高熵、易于共享且易于轮换的密码
  2. 将其设置为您的密钥库密码
  3. 根据您认为合适的方式分发加密的密钥库
  4. 无论收到什么,密钥库都会调用 Vault 来获取与您在第一步中使用的完全相同的密码(使用完全相同的命令)。

Your keystore is in binary format... There might an encoding issue. Try this instead:

vault write -address {$VAULT_ADDR} ${SECRET_PATH} keystore=$(openssl base64 -A -in myKeys.keystore)

And get it back with

vault read -address {$VAULT_ADDR} --field keystore ${SECRET_PATH} | openssl base64 -d -A > myKeys.keystore

But a Java keystore is already encrypted... Why don't you use Vautl for password management? Perfect use case for this:

  1. Use Vault to generate a high-entropy, easy to share password that is easy to rotate.
  2. Set it as your keystore password
  3. Distribute the encrypted keystore as you see fit
  4. Whatever receices the keystore calls Vault to get the exact same password you had at step one (using the exact same command).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文