Why can't I update my Nodebalancer's SSL certificate with Linode API?

Linode Staff

When following this guide to update my Nodebalancer's SSL certificate utilizing the Linode API

I have a shell script that sets the variables below then executes:

curl -H "Content-Type: application/json"
-H "Authorization: Bearer $TOKEN"
-X PUT -d @$JSON
https://api.linode.com/v4/nodebalancers/$NODE_ID/configs/$CONFIG_ID

I am getting this error

{"errors": [{"reason": "Could not load private key.", "field": "ssl_key"}, {"reason": "Could not load certificate.", "field": "ssl_cert"}]}

I have also tried using POST instead of PUT with the API call and I get a Could not load certificate error.

Please help me figure out how to get this to work.

1 Reply

The SSL key and SSL certificate are likely not formatted properly to be read by the API. The commands I am including below format the raw contents of your ssl_key and ssl_cert files to be on a single line with \n, the new line character, for line breaks.

awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' /path/to/cert > ReformattedCertName
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' /path/to/key > ReformattedKeyName

Then paste the formatted data into your json data. This sort of formatting is required for most Restful APIs in order for them to properly parse the information.



In regards to trying POST instead of PUT with this API call, POST is unsupported in this specific API call which is why you got the Could not load certificate error.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct