RSA public / private keys in YAML

I need to save the RSA key pair in a YAML file, but still a limited understanding of yaml syntax and lack of examples allows me to search for an answer.

I’m just starting to work with what I have, but I was wondering if someone could quickly and briefly explain how I can store something like that in the hole.

+10
source share
3 answers

You can store your keys as text ("ASCII-armored" / base 64 encoded). From Wikipedia, the syntax for multiline strings in YAML is:

- title: An example multi-line string in YAML body : | This is a multi-line string. "special" metacharacters may appear here. The extent of this string is indicated by indentation. 
+14
source

Starting October 27, 2016, this is the first Google search for “yaml rsa key”, so I would like to add an answer to the specific syntax needed for Yamaha RSA keys.

If you include the key on one line in the yaml file, there is no problem. If you want to split it on different lines for readability, and you cannot accept newlines in the generated line, the only option seems to be double quotes with escape codes.

In my case, I needed a generated single-line string with no spaces, since the key definition was used by the template engine to insert the key into the script variable. The following syntax is attached to each line without spaces (note the "\" in each line to remove translation lines):

  yourKey: "-----BEGIN PUBLIC KEY-----\ xxx...\ yyy...\ zzz...\ -----END PUBLIC KEY-----" result: "-----BEGIN PUBLIC KEY-----xxx...yyy...zzz...-----END PUBLIC KEY-----" 

A very good link to the formats for literals can be found here on SO: https://stackoverflow.com/a/16815/

+5
source

It is recommended that you store the keys in a yaml file by creating pem files

  security: publickeypemfile: /config/env/xyz.pem keystorefile: /secret/pqr.jks testmode: true xyz.pem: |- -----BEGIN PUBLIC KEY—— Line 1 Line 2 Line 3 ………………………………………. -----END PUBLIC KEY----- 
0
source

All Articles