Skip to content

Commit f8e27d0

Browse files
authored
Fix SelfSignedCertificateMockServer code analysis errors (#5739)
1 parent 1501b1a commit f8e27d0

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

test/TestUtilities/Test.Utility/SelfSignedCertificateMockServer.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Net;
88
using System.Net.Security;
99
using System.Net.Sockets;
10-
using System.Security.Authentication;
1110
using System.Security.Cryptography;
1211
using System.Security.Cryptography.X509Certificates;
1312
using System.Text;
@@ -18,7 +17,7 @@
1817

1918
namespace Test.Utility
2019
{
21-
public class SelfSignedCertificateMockServer
20+
public class SelfSignedCertificateMockServer : IDisposable
2221
{
2322
private readonly X509Certificate2 _certificate;
2423
private readonly string _packageDirectory;
@@ -199,6 +198,17 @@ private static X509Certificate2 GenerateSelfSignedCertificate()
199198
return new X509Certificate2(certBytes, "password", X509KeyStorageFlags.Exportable);
200199
}
201200
}
201+
202+
public void Dispose()
203+
{
204+
_tcpListener.Stop();
205+
206+
#if NET8_0_OR_GREATER
207+
_tcpListener.Dispose();
208+
#endif
209+
210+
_certificate.Dispose();
211+
}
202212
}
203213

204214
internal class Resource

0 commit comments

Comments
 (0)