How did I fix «Unfortunately, operation failed due to unexpected error» on installing a custom SSL certificate to Cloudways?

{
	"status": false,
	"message": "",
	"response": {
		"error": {
			"host_result": {
				"actual_error": "",
				"error": "",
				"status": -999999
			}
		},
		"status": false,
		"task_info": {
			"ignore_errors": false,
			"playbook_name": "Handles ssl related processes",
			"playbook_path": "..\/playbook\/ansible-cg-server-other\/ssl\/site.yml",
			"post_run_state": "OK",
			"pre_run_state": "OK",
			"run_state": "FAILED_HOSTS",
			"task_name": "TASK (custom : common - Verify certificate (so that it corresponds to key on server))",
			"task_result": "FAILED",
			"uid": "a8e90fc4-1b82-11f0-84ea-16c4ea784512"
		},
		"code": -999999,
		"message": "",
		"display_message": "Unfortunately, operation failed due to unexpected error."
	},
	"error_category": "user"
}

I fixed it by reordering the certificates: putting the application certificate before its CA chain.