puppethiera

Decrypt using Old private key (pair) and re encrypt using new Private key(pair) in hiera eyaml?


i want to encrypt the sensitive information in a yaml using a private/public key pair. When that key pair expires or changed, the file has to decrypted using the old key pair and re-encrypted using the key pair.

here is my file test.yaml

application::user: admin
application::password: passkey

I edited using eyaml edit test.yaml and changed to

application::user: admin
application::password: DEC::PKCS7[passkey]!

Now when i vi test.yaml, i can see

application::user: admin
application::password : ENC[PKCS7,blahBlahEncryptedBlahBlah]

now what i want to do is,

eyaml createkeys

creates a different set of public and private keys and i want to re-encrypt the test.yaml file using the new set of keys.

How do i do that?

PS: I don't want to use gpg keyring


Solution

  • Found the answer.

    I decrypted to plaintext (base64) using the old keys and then re-encrypted to pkcs7 format using the new keys. Thanks, please mark this one as fixed