Keys in node attributes


#1

Hi,

Using ChefZero and pushing an attributes json file up to the host via another mechanism. I want to store the private key in the json file as a node attribute, then use a file template resource to push that out to a file on disk.

{
“project”: {
“ssl_private_key”: “-----BEGIN RSA PRIVATE KEY-----
FIRST LINE OF KEY

LAST LINE OF KEY
-----END RSA PRIVATE KEY-----”
}
}

This fails because I have lfs in the json file. I have tried this with \n for each line, and this gets further but produces a key which is unusable.

Any other suggestions on the best way to do this?

Thanks.
Andrew.


#2

I successfully encoded the private key and cert as two entries like this:

{
  "id": "webcert",
  "key": "-----BEGIN RSA PRIVATE KEY-----\nMII...==\n-----END RSA PRIVATE KEY-----\n",
  "cert": "-----BEGIN CERTIFICATE-----\nMII...\n-----END CERTIFICATE-----\n"
}

I replaced the actual key and cert data with ‘…’. I would also suggest putting this in an encrypted data bag at the very minimum.