Skip to content

Commit 20c0c3b

Browse files
author
rstam
committed
CSHARP-658: Added a test certificate so SslSettingsTests pass on Mono also.
1 parent c0a2879 commit 20c0c3b

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pfx binary

MongoDB.DriverUnitTests/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# openssl artifacts
2+
*.rnd

MongoDB.DriverUnitTests/MongoDB.DriverUnitTests.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@
227227
<Install>true</Install>
228228
</BootstrapperPackage>
229229
</ItemGroup>
230+
<ItemGroup>
231+
<None Include="testcert.pfx">
232+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
233+
</None>
234+
</ItemGroup>
230235
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
231236
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
232237
Other similar extension points exist, see Microsoft.Common.targets.
@@ -235,4 +240,4 @@
235240
<Target Name="AfterBuild">
236241
</Target>
237242
-->
238-
</Project>
243+
</Project>

MongoDB.DriverUnitTests/SslSettingsTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void TestClientCertificates()
6666
var settings = new SslSettings();
6767
Assert.AreEqual(null, settings.ClientCertificates);
6868

69-
var clientCertificates = new[] { new X509Certificate(), new X509Certificate() };
69+
var clientCertificates = new[] { new X509Certificate2("testcert.pfx", "password"), new X509Certificate2("testcert.pfx", "password") };
7070
settings.ClientCertificates = clientCertificates;
7171
Assert.IsTrue(clientCertificates.SequenceEqual(settings.ClientCertificates));
7272
Assert.AreNotSame(clientCertificates[0], settings.ClientCertificates.ElementAt(0));
@@ -98,7 +98,7 @@ public void TestClone()
9898
var settings = new SslSettings
9999
{
100100
CheckCertificateRevocation = false,
101-
ClientCertificates = new[] { new X509Certificate() },
101+
ClientCertificates = new[] { new X509Certificate2("testcert.pfx", "password") },
102102
ClientCertificateSelectionCallback = ClientCertificateSelectionCallback,
103103
EnabledSslProtocols = SslProtocols.Tls,
104104
ServerCertificateValidationCallback = ServerCertificateValidationCallback
@@ -131,7 +131,7 @@ public void TestEquals()
131131
Assert.AreNotEqual(settings, clone);
132132

133133
clone = settings.Clone();
134-
clone.ClientCertificates = new[] { new X509Certificate() };
134+
clone.ClientCertificates = new[] { new X509Certificate2("testcert.pfx", "password") };
135135
Assert.AreNotEqual(settings, clone);
136136

137137
clone = settings.Clone();

MongoDB.DriverUnitTests/testcert.pfx

1.61 KB
Binary file not shown.

0 commit comments

Comments
 (0)