Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@ namespace System.Net.Security.Tests
{
using Configuration = System.Net.Test.Common.Configuration;

public class SslStreamNetworkStreamTest : IDisposable
public class SslStreamNetworkStreamTest
{
private readonly X509Certificate2 _serverCert;
private readonly X509Certificate2Collection _serverChain;
private static readonly X509Certificate2 _serverCert;
private static readonly X509Certificate2Collection _serverChain;

public SslStreamNetworkStreamTest()
static SslStreamNetworkStreamTest()
{
(_serverCert, _serverChain) = TestHelper.GenerateCertificates("localhost", this.GetType().Name);
}

public void Dispose()
{
TestHelper.CleanupCertificates(this.GetType().Name);
string name = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name.ToString();
TestHelper.CleanupCertificates(name);
(_serverCert, _serverChain) = TestHelper.GenerateCertificates("localhost", name);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.X509Certificates.Tests.Common;
using System.Runtime.CompilerServices;
using System.Text;

namespace System.Net.Security.Tests
Expand Down Expand Up @@ -107,7 +108,8 @@ internal static void CleanupCertificates(string testName)
}
catch { };
}
internal static (X509Certificate2 certificate, X509Certificate2Collection) GenerateCertificates(string targetName, string? testName = null)

internal static (X509Certificate2 certificate, X509Certificate2Collection) GenerateCertificates(string targetName, [CallerMemberName] string? testName = null)
{
if (PlatformDetection.IsWindows && testName != null)
{
Expand Down