C# FindBySubjectName 函数

C# FindBySubjectName function

为什么:

foundCertificates = certificates.Find(X509FindType.FindBySubjectName, "TEXT 14", false);

找到与

相同的证书
foundCertificates = certificates.Find(X509FindType.FindBySubjectName, "TEXT 141", false);

如果我指定我想要 "TEXT 141" 它不应该 select "TEXT 14" 对我来说。

我该如何解决?

来自 documentationX509FindType.FindBySubjectName 枚举成员:

Using the FindBySubjectName value, the Find method performs a case-insensitive string comparison using the supplied value. For example, if you pass "MyCert" to the Find method, it will find all certificates with the subject name containing that string, regardless of other subject values. Searching by distinguished name is a more precise search.

因此,如果您想要精确匹配,请改用 X509FindType.FindBySubjectDistinguishedName