How to store the content of binary file in Vault?

What is the best way to store a content of binary file in Vault ? Any recommendation ?

What is the use case you need to store a binary file? I’d say that isn’t a normal thing in Vault.

I’d recommend using transit to encrypt the file but storing the encrypted content in your existing storage/db platform.

The file has sensitive content (certificates) - it is jks file.

Hello,

Did you try to convert it to base64 and they put it in Vault ?

Martin

No I haven’t. I didn’t know it has to be converted to base64. Once I did that what vault command should I use to write the content to Vault ?

I think you can use the API below

curl \
    --header "X-Vault-Token: ..." \
    --request POST \
    --data @payload.json \
    http://127.0.0.1:8200/v1/transit/encrypt/my-key
1 Like

I use base64 for store all binary content or something like this.

Encode and put to vault

base64 --wrap=0 /tmp/cert.p12  | vault kv put mysecrets/my-cert key=-

Get from vault and decode

vault kv get -field=key mysecrets/my-cert | base64 --decode --ignore-garbage > /tmp/my-cert.p12
2 Likes