Description
Describe the bug
The unauthenticated endpoint for retrieving the ssh engine CA public key returns text/plain, while typically vault responds to requests with a JSON object.
This breaks the unauthenticated vault read /path/to/ssh/public_key
, but more importantly it breaks the same trying to render a template, presumably because the view/renderer is expecting JSON.
To Reproduce
Steps to reproduce the behavior:
- Run
vault read /ssh/public_key
- See error below
CLI:
╰─± vault read /ssh/public_key
Error reading /ssh/public_key: invalid character 's' looking for beginning of value
template:
Feb 18 23:34:14 ip-172-20-20-40 vault[12298]: 2023-02-18T23:34:14.652Z [ERROR] runtime error encountered: error="template server: vault.read(/ssh/public_key): vault.read(/ssh/public_key): invalid character 's' looking for beginning of value"
The first part of the ssh key is is ssh-rsa
- I believe where the message invalid character 's'
is coming from.
Further, attempts to coerce the server into replying with JSON are ignored:
$ curl -vvvvv -H "Accept: application/json" https://my.vault.com:8200/v1/ssh/public_key
> GET /ssh/public_key HTTP/2
> Host: vault.sev1tech.com:8200
> User-Agent: curl/7.61.1
> Accept: application/json
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 200
< date: Sat, 18 Feb 2023 23:19:07 GMT
< content-type: text/plain
Expected behavior
Most likely one of these two things are expected to happen:
- The endpoint should either honor an
Accept: application/json
header, outright return JSON instead of plain/text, or default to JSON but allow and honor a client'sAccept: text/plain
header. - The renderer/viewer honors the server's
Content-Type
headertext/plain
and handles it accordingly, rather than assuming the response is JSON and crashing/erroring.
Environment:
- Vault Server Version: 1.12.2
- Vault CLI Version: 1.12.2
- Server Operating System/Architecture: Linux/x86
Additional Context:
AFAICT, this issue forces the use of the authenticated endpoint for retrieving the public_key
in a vault template, which also forces granting read
capability to /ssh/config/ca
. I haven't been able, by trial or reading the consul template docs, to modify the behavior to handle a text/plain
server response.
Activity