Problem connecting Basics Station to TTS

I’m running Basics Station on an RPi4 but having problems trying to connect to The Things Stack. I think I’ve got CUPS working - station reports Interaction with CUPS done - next regular check in 1d and writes a bunch of tc.x files - but Starting TC engine fails with Recv failed: SSL - The peer notified us that the connection is going to be closed

Of the tc.x files written by station, tc.key contains the LNS key that I created on TTS with … Oh, I’ve just seen. The tc.key file written by station is wrong.

It contains:
Authorization: NNSXS.thekeyfirsthalf.keysecondhalfNNSXS.thekeyfirsthalf.keysecondhalf

If I edit tc.key so it contains:
Authorization: NNSXS.thekeyfirsthalf.keysecondhalf

station connects properly once but then CUPS provides some “updates” and messes up the key file again.

The repeated key characters are in the http body returned by:
dbuf_t body = http_getBody(&cups->hc);
in cups.c so it doesn’t look like a problem with Basics Station.