Skip to content

Commit 3c6bc5b

Browse files
committed
Add IgnoreX509NameOrdering property
- see #136
1 parent 04db759 commit 3c6bc5b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

crypto/src/x509/store/X509CertStoreSelector.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class X509CertStoreSelector
2121
private X509Certificate certificate;
2222
private DateTimeObject certificateValid;
2323
private ISet extendedKeyUsage;
24+
private bool ignoreX509NameOrdering;
2425
private X509Name issuer;
2526
private bool[] keyUsage;
2627
private ISet policy;
@@ -43,6 +44,7 @@ public X509CertStoreSelector(
4344
this.certificate = o.Certificate;
4445
this.certificateValid = o.CertificateValid;
4546
this.extendedKeyUsage = o.ExtendedKeyUsage;
47+
this.ignoreX509NameOrdering = o.IgnoreX509NameOrdering;
4648
this.issuer = o.Issuer;
4749
this.keyUsage = o.KeyUsage;
4850
this.policy = o.Policy;
@@ -95,6 +97,12 @@ public ISet ExtendedKeyUsage
9597
set { extendedKeyUsage = CopySet(value); }
9698
}
9799

100+
public bool IgnoreX509NameOrdering
101+
{
102+
get { return ignoreX509NameOrdering; }
103+
set { this.ignoreX509NameOrdering = value; }
104+
}
105+
98106
public X509Name Issuer
99107
{
100108
get { return issuer; }
@@ -140,7 +148,8 @@ public X509Name Subject
140148
set { subject = value; }
141149
}
142150

143-
public string SubjectAsString
151+
[Obsolete("Avoid working with X509Name objects in string form")]
152+
public string SubjectAsString
144153
{
145154
get { return subject != null ? subject.ToString() : null; }
146155
}
@@ -212,7 +221,7 @@ public virtual bool Match(
212221
}
213222
}
214223

215-
if (issuer != null && !issuer.Equivalent(c.IssuerDN, true))
224+
if (issuer != null && !issuer.Equivalent(c.IssuerDN, !ignoreX509NameOrdering))
216225
return false;
217226

218227
if (keyUsage != null)
@@ -277,7 +286,7 @@ public virtual bool Match(
277286
if (serialNumber != null && !serialNumber.Equals(c.SerialNumber))
278287
return false;
279288

280-
if (subject != null && !subject.Equivalent(c.SubjectDN, true))
289+
if (subject != null && !subject.Equivalent(c.SubjectDN, !ignoreX509NameOrdering))
281290
return false;
282291

283292
if (!MatchExtension(subjectKeyIdentifier, c, X509Extensions.SubjectKeyIdentifier))

0 commit comments

Comments
 (0)