How to insert a jks file in Vault Hashicorp?

Viewed 1906

I have a jks file which I need to put in Vault but before putting the jks file it should be base64 encoded and saved as json. This is the process in short -

encoding the jks to base64 --> Storing the string in a file --> Modify to json --> Store to vault

Here is what I am doing -

#encode and store it in a file
cat my-jks-file.jks | base64 > my-jks-file.txt

#Manually convert this to a json file which looks like this -
{
  "my-secret" : <base64 string>
}

#Put this inside vault
vault kv put kv/foo @converted-jks-file.json

Is there a better way to do this? I want to avoid the manual step. Thanks

1 Answers

After doing a some research and going through the docs here -https://www.vaultproject.io/docs/commands/kv/put

I found a way to do this all in a single line

cat my-jks-file.jks | base64 | vault kv put kv/my-new-secret vault-jks=-
Related