Updating GitLab Pages certificate with API gives 400 Bad Request

Hello,

I have an automated pipeline job that renews a certificate for one of my gitlab pages domain. The code obtains certificates from Let’s Encrypt and then update the GitLab Pages cert with:

curl \
  --verbose \
  --fail \
  --show-error \
  --request PUT \
  -H "PRIVATE-TOKEN: $GITLAB_API_KEY" \
  --form "certificate=@$CERT_FILE" \
  --form "key=@$KEY_FILE" \
  https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/pages/domains/$DOMAIN

This command worked for months but is now failing with 400 Bad Request. No more detail. A GET on the domain config works.

Any hint?

thanks,
-fred

I noticed GitLab can now handle the Let’s Encrypt cert automatically so I’m going to try this on another domain as a test but still I’d like to understand why the API is failing