为什么:
foundCertificates = certificates.Find(X509FindType.FindBySubjectName, "TEXT 14", false);
查找与
相同的证书foundCertificates = certificates.Find(X509FindType.FindBySubjectName, "TEXT 141", false);
如果我指定我想要“TEXT 141”,它不应该为我选择“TEXT 14”。
我该如何解决?
最佳答案
来自documentation对于 X509FindType.FindBySubjectName
枚举成员:
Using the
FindBySubjectName
value, theFind
method performs a case-insensitive string comparison using the supplied value. For example, if you pass "MyCert" to theFind
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
。
关于C# FindBySubjectName 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32633558/