mikefourie-zz / MSBuildExtensionPack

MIT License
366 stars 104 forks source link

MSBuild.ExtensionPack.Security.Certificate SetUserRights TaskAction cannot find a certificate by the SubjectDName returned by Add TaskAction #15

Closed icraftsoftware closed 6 years ago

icraftsoftware commented 9 years ago

I think the reason might lie in the following code

private static X509Certificate2 GetCertificateFromDistinguishedName(string distinguishedName, X509Store certificateStore)
{
   // Iterate through each certificate trying to find the first unexpired certificate
   return certificateStore
      .Certificates.Cast<X509Certificate2>()
      .FirstOrDefault(certificate => string.Compare(
         certificate.Subject,
         distinguishedName,
         StringComparison.CurrentCultureIgnoreCase) == 0);
}

that should rather compare distinguishedName parameter against certificate.SubjectName.Name instead of certificate.Subject. (At least for the sake of consistency with what Add and GetInfo TaskActions do.)