d5c9eec3fb
Extending -DnsName or -IpAddress and re-running returned the existing certificate, which lacked the name that had just been added - the reuse check compared only the common name. A candidate must now carry every requested name, and the name that disqualified it is reported so the reissue is explainable. Reading SANs back off an installed certificate needs a decoder: netstandard2.0 has no X509SubjectAlternativeNameExtension, and X509Extension.Format produces localized text that cannot be compared. The extension is decoded from its DER bytes with BouncyCastle, already carried for CSR generation. The rule is coverage rather than equality, since a certificate carrying more names than requested still satisfies the request. DNS names compare case-insensitively and IP addresses are normalized through IPAddress, so ::1 and 0:0:0:0:0:0:0:1 are the same name. Trimming the SAN set therefore still reuses; -Force covers that case. FindMatch keeps its original four-argument overload so existing callers are unaffected, and only reports a rejected name when no candidate qualified. Verified against a live CurrentUser\My store with a certificate carrying SANPROBE, SANPROBE.contoso.com and 10.20.30.40: identical and subset requests reuse, a new DNS name or IP forces reissue naming the missing entry, differing case reuses, and an empty request reuses. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>