Skip to content
Merged
Changes from all commits
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 @@ -179,7 +179,13 @@ public async Task ServerSession_TlsResume_HonorsAllowTlsResumeOption(SslProtocol
}

using X509Certificate2 serverCert = TestCertificates.GetServerCertificate();
string serverName = serverCert.GetNameInfo(X509NameType.SimpleName, forIssuer: false);

// Use a unique SNI name, as SslStreamTlsResumeTests does. The client-side session cache
// lives on a process-wide SSL_CTX shared by every client with the same protocols and
// client certificate, and holds a single session per SNI name. With the certificate
// name, a test running concurrently in this assembly can overwrite our cached ticket
// with one issued by its own server, which this server then cannot decrypt.
string targetHost = Guid.NewGuid().ToString("N");

using TlsContext serverCtx = TlsContext.CreateServer(new SslServerAuthenticationOptions
{
Expand All @@ -189,8 +195,8 @@ public async Task ServerSession_TlsResume_HonorsAllowTlsResumeOption(SslProtocol
AllowTlsResume = allowResume,
});

long bytes1 = await MeasureHandshakeBytesAsync(serverCtx, serverName, protocol);
long bytes2 = await MeasureHandshakeBytesAsync(serverCtx, serverName, protocol);
long bytes1 = await MeasureHandshakeBytesAsync(serverCtx, targetHost, protocol);
long bytes2 = await MeasureHandshakeBytesAsync(serverCtx, targetHost, protocol);

if (allowResume)
{
Expand All @@ -211,7 +217,7 @@ public async Task ServerSession_TlsResume_HonorsAllowTlsResumeOption(SslProtocol
}
}

private static async Task<long> MeasureHandshakeBytesAsync(TlsContext serverCtx, string serverName, SslProtocols protocol)
private static async Task<long> MeasureHandshakeBytesAsync(TlsContext serverCtx, string targetHost, SslProtocols protocol)
{
(Socket cs, Socket ss) = await CreateLoopbackSocketPairAsync();
using (cs)
Expand All @@ -224,7 +230,7 @@ private static async Task<long> MeasureHandshakeBytesAsync(TlsContext serverCtx,

Task clientHandshake = clientSsl.AuthenticateAsClientAsync(new SslClientAuthenticationOptions
{
TargetHost = serverName,
TargetHost = targetHost,
EnabledSslProtocols = protocol,
RemoteCertificateValidationCallback = TestHelper.AllowAnyServerCertificate,
});
Expand Down
Loading