**Related issue:** Resolves #36717 When gitops runs and the yml for a certificate template includes a change to a certificate authority or a subject name for an existing certificate template. Do not update the certificate template, delete the old one and create a new one. This will aid in ensuring the new certificate is sent to the android device. # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) ## Testing - [x] Added/updated automated tests - [x] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [x] QA'd all new/changed functionality manually <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Enhanced certificate template comparison logic to properly detect changes in certificate authority associations and subject names, ensuring certificates are recreated when needed. * **Tests** * Expanded test coverage for certificate template management scenarios, including updates to certificate authorities and subject name modifications. * Added validation for certificate deletion and recreation workflows under various configuration changes. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Victor Lyuboslavsky <2685025+getvictor@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>