Skip to content

Commit 12fba2e

Browse files
CSHARP-3962: Fix X509CertificateCollectionEqualityComparer comparing logic. (#691)
1 parent fff5e6a commit 12fba2e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/MongoDB.Driver/SslSettings.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,11 @@ private class X509CertificateCollectionEqualityComparer : IEqualityComparer<X509
269269
{
270270
public bool Equals(X509CertificateCollection lhs, X509CertificateCollection rhs)
271271
{
272-
if (lhs == null) { return rhs == null; }
272+
if (lhs == null || rhs == null)
273+
{
274+
return rhs == lhs;
275+
}
276+
273277
return ((IEnumerable)lhs).Cast<X509Certificate>().SequenceEqual(((IEnumerable)rhs).Cast<X509Certificate>());
274278
}
275279

tests/MongoDB.Driver.Tests/SslSettingsTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public void TestEquals()
137137
var certificateFileName = GetTestCertificateFileName();
138138
clone.ClientCertificates = new[] { new X509Certificate2(certificateFileName, "password") };
139139
Assert.NotEqual(settings, clone);
140+
Assert.NotEqual(clone, settings);
140141

141142
clone = settings.Clone();
142143
clone.ClientCertificateSelectionCallback = ClientCertificateSelectionCallback;

0 commit comments

Comments
 (0)