public async Task HttpClient_ClientUsesAuxRecord_Ok() { var options = new HttpsTestServer.Options(); options.AllowedProtocols = SslProtocols.Tls; using (var server = new HttpsTestServer(options)) using (HttpClientHandler handler = CreateHttpClientHandler()) using (HttpClient client = CreateHttpClient(handler)) { handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; server.Start(); var tasks = new Task[2]; bool serverAuxRecordDetected = false; bool serverAuxRecordDetectedInconclusive = false; int serverTotalBytesReceived = 0; int serverChunks = 0; CircularBuffer buffer = new CircularBuffer(4); tasks[0] = server.AcceptHttpsClientAsync((requestString) => { buffer.Add(requestString); serverTotalBytesReceived += requestString.Length; if (serverTotalBytesReceived == 1 && serverChunks == 0) { serverAuxRecordDetected = true; } serverChunks++; // Test is inconclusive if any non-CBC cipher is used: if (server.Stream.CipherAlgorithm == CipherAlgorithmType.None || server.Stream.CipherAlgorithm == CipherAlgorithmType.Null || server.Stream.CipherAlgorithm == CipherAlgorithmType.Rc4) { serverAuxRecordDetectedInconclusive = true; } // Detect end of HTML request if (buffer.Equals("\r\n\r\n")) { return(Task.FromResult(HttpsTestServer.Options.DefaultResponseString)); } else { return(Task.FromResult <string>(null)); } }); string requestUriString = "https://localhost:" + server.Port.ToString(); tasks[1] = client.GetStringAsync(requestUriString); await tasks.WhenAllOrAnyFailed(15 * 1000); if (serverAuxRecordDetectedInconclusive) { _output.WriteLine("Test inconclusive: The Operating system preferred a non-CBC or Null cipher."); } else { Assert.True(serverAuxRecordDetected, "Server reports: Client auxiliary record not detected."); } } }