Skip to content

Commit ec2fd3f

Browse files
committed
Mitigate missing dev cert in a way that doesn't invalidate the test
1 parent cb5ceac commit ec2fd3f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/DefaultBuilder/test/Microsoft.AspNetCore.TrimmingTests/UseHttpsDoesDependOnX509Test.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Security.Cryptography.X509Certificates;
23
using Microsoft.AspNetCore.Builder;
34
using Microsoft.AspNetCore.Hosting;
@@ -8,13 +9,18 @@
89
{
910
serverOptions.ListenLocalhost(5000, listenOptions =>
1011
{
11-
#pragma warning disable SYSLIB0026 // The constructor obsolete but we're not actually going to use the cert
12-
listenOptions.UseHttps(new X509Certificate2());
13-
#pragma warning restore SYSLIB0026
12+
listenOptions.UseHttps();
1413
});
1514
});
1615

17-
var app = builder.Build();
16+
try
17+
{
18+
_ = builder.Build();
19+
}
20+
catch (InvalidOperationException)
21+
{
22+
// Expected if there's no dev cert installed
23+
}
1824

1925
if (!X509Utilities.HasCertificateType) {
2026
return 1;

0 commit comments

Comments
 (0)