Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSL Certificate to JSON

I need to send a SSL Certificate as a string via JSON to my server. On the server I need to reconstruct the JSON string to a valid certificate. My problems are the spaces and line brakes in the certificate.

How can I preserve the correct format of the certificate?

like image 314
j7nn7k Avatar asked Jan 28 '13 10:01

j7nn7k


1 Answers

The problem was indeed related to the white spaces and line brakes.

Here is what worked for me:

  1. Copied the certificate into a one line text field. Not very elegant but it's a quick way to make a one line string out of it. Most text editors can do that, too i guess.

  2. Replaced the line brakes (now white spaces) with "\n". Do not replace the white spaces between those phrases -----BEGIN RSA PRIVATE KEY----- they can stay as they are.

Example:

{
"key": "-----BEGIN RSA PRIVATE KEY-----\njlQvt9WdR9Vpg3WQT5+C3HU17bUOwvhp/r0+viMcBUCRW85UqI2BJJKTi1IwQQ4c\ntyTrhYJYOP+A6JXt5BzDzZy/B7tjEMDBosPiwH2m4MaP+6wTbi1qR1pFDL3fXYDr\n"
}
like image 51
j7nn7k Avatar answered Sep 28 '22 06:09

j7nn7k