How can you insert tlsCACert using the Datasources HTML API. I’ve tried placing tlsCACert inside secureJsonData, and see this being imported in to the DB, but it never works. If I copy the pem and pasted into the datasources API, then save and test it works. Seems like the JSON import is not working
you are doin everything right. now it depends on a small detail that you did wrong and not explain here
The only difference I can see is the pem is multi-line, and if I paste this into the datasource UI it works OK, but if I put into the JSON I have to joint it into a single line. I can’t see any other difference.
Here is an example of a CURL command to to the same - with credentials anonymized removed
curl -d ‘{ “id”: 123, “orgId”: 1, “name”: “ds-name”, “type”: “mysql”, “typeLogoUrl”: “public/app/plugins/datasource/mysql/img/mysql_logo.svg”, “access”: “proxy”, “url”: “db-endpoint”, “user”: “db-username”, “database”: db-name", “basicAuth”: false, “isDefault”: false, “jsonData”:{ “keepCookies”: [], “tlsAuthWithCACert”:true, “tlsCACert”:"-----BEGIN CERTIFICATE-----…-----END CERTIFICATE-----"}, “secureJsonData”:{ “password”: “db-password” }, “readOnly”: false }’ -H ‘Content-Type: application/json’ -H ‘Accept: application/json’ -H ‘Authorization: Bearer auth-key’ -X PUT https://metrics.sense.ly/api/datasources/123
your certificate looks a bit strange, never seen such a thing. and Are you sure that everything is also good with encoding? what is in the error logs?
Correct, tlsCACert
must be single line string. Just replace all line ends with \n
string, e.g.
"-----BEGIN CERTIFICATE-----\n...\n…\n-----END CERTIFICATE-----"
+ you have wrong payload structure. Update datasource in the browser with open network browser console and copy request payload from the network console from that update request, so you will have correct payload. UI also uses API, so just “sniff” it with the browser console.
Thanks - the \n worked - good tip on using the sniffer also.
This topic was automatically closed after 365 days. New replies are no longer allowed.