SSL Certificate to JSON

六眼飞鱼酱① 提交于 2020-02-03 05:41:06

问题


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?


回答1:


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"
}


来源:https://stackoverflow.com/questions/14560393/ssl-certificate-to-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!