SSL证书转JSON [英] SSL Certificate to JSON
问题描述
我需要通过JSON将SSL证书作为字符串发送到我的服务器。在服务器上,我需要将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?
推荐答案
问题确实与空白和行制动器有关。
The problem was indeed related to the white spaces and line brakes.
这对我有用:
-
将证书复制到一行文本字段中。虽然不是很优雅,但这是从中制作一行字符串的快速方法。我猜大多数文本编辑器也可以做到这一点。
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.
将行制动器(现在为空白)替换为 \n。不要替换这些短语 ----- BEGIN RSA PRIVATE KEY -----
之间的空格,它们可以保持原样。
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.
示例:
{
"key": "-----BEGIN RSA PRIVATE KEY-----\njlQvt9WdR9Vpg3WQT5+C3HU17bUOwvhp/r0+viMcBUCRW85UqI2BJJKTi1IwQQ4c\ntyTrhYJYOP+A6JXt5BzDzZy/B7tjEMDBosPiwH2m4MaP+6wTbi1qR1pFDL3fXYDr\n"
}
这篇关于SSL证书转JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!