我尝试使用 Vault pki 角色生成证书。如何从 wget 命令输出创建一个名为 ca.crt 的单个文件。
$ wget --method=POST --header="X-Vault-Namespace: ns" --header="X-Vault-Token: $VAULT_TOKEN" --body-data='{"common_name": "test.example.com", "ttl": "5m"}' https://127.0.0.1:8200/v1/pki/dev/issuing_ca/issue/dev -q -O - | jq '.data.ca_chain'
Response
[
"-----BEGIN CERTIFICATE-----\nMIIF5jCCA86W6j2PehfjWs3\nR55ogX1Z2jk/dvIIp.......Z067gh7nrDE56fzhyA=\n-----END CERTIFICATE-----",
"-----BEGIN CERTIFICATE-----\nMIIF4DCCA8iNzdTHItwqVl1cTglr6bcry0vckey68u+.......4gR0CRtJ\nCaLcNKCBGi/jn6pekNVvgjBamsM=\n-----END CERTIFICATE-----",
"-----BEGIN CERTIFICATE-----\nMIIFMzCCAxnNDE5MTlaFwumZ8\nHL8n10r0b35LtMT........CxSXIjAZJRE8Fh9jOIm0\n-----END CERTIFICATE-----"
]
$ cat ca.crt
-----BEGIN CERTIFICATE-----
MIIF5jCCA86W6j2PehfjWs3
.
.
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIF5jCCA86W6j2PehfjWs3
.
.
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
nMIIF4DCCA8iNzdTHItwqVl1c
.
.
-----END CERTIFICATE-----