67cf0abac2
Switching certificate profiles returned the existing certificate instead of issuing a new one. The reuse check searched Infisical by common name and status only, so a host already holding a server-authentication certificate for its own name was handed that certificate back when asking a client-authentication profile - same subject, wrong extended key usages. The search is now scoped by -CertificateProfileId or -CertificateAuthorityId. Both filters already existed on InfisicalCertificateSearchQuery and serialize as profileIds/caIds; the reuse path simply never set them. The subscriber path needs no filter because a subscriber pins its own common name, so matching the name is already equivalent to matching the subscriber. A second defect compounded it: InfisicalLocalCertificateLookup.FindMatch only applies its serial filter when the candidate set is non-empty, so a search that legitimately returned nothing degraded into a name-only local match - exactly the case that hands back another issuer's certificate. A completed search that finds nothing is now a definite "nothing to reuse". The lenient fallback is kept for the case where Infisical cannot be reached, since failing a renewal because the API is down is worse, but it now announces itself as a warning rather than being silent. Reuse still does not compare subject alternative names; that gap is documented with -Force as the workaround rather than half-addressed here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>