/// <summary> /// Implementation of the test itself. /// </summary> /// <returns>true if the test passes, false otherwise.</returns> public override async Task <bool> RunAsync() { IPAddress ServerIp = (IPAddress)ArgumentValues["Server IP"]; int NonCustomerPort = (int)ArgumentValues["clNonCustomer Port"]; log.Trace("(ServerIp:'{0}',NonCustomerPort:{1})", ServerIp, NonCustomerPort); bool res = false; Passed = false; ProtocolClient client = new ProtocolClient(); try { MessageBuilder mb = client.MessageBuilder; // Step 1 await client.ConnectAsync(ServerIp, NonCustomerPort, false); log.Trace("Entering 180 seconds wait..."); await Task.Delay(180 * 1000); log.Trace("Wait completed."); // We should be disconnected by now, so TLS handshake should fail. bool disconnectedOk = false; SslStream sslStream = null; try { sslStream = new SslStream(client.GetStream(), false, PeerCertificateValidationCallback); await sslStream.AuthenticateAsClientAsync("", null, SslProtocols.Tls12, false); } catch { log.Trace("Expected exception occurred."); disconnectedOk = true; } if (sslStream != null) { sslStream.Dispose(); } // Step 1 Acceptance Passed = disconnectedOk; res = true; } catch (Exception e) { log.Error("Exception occurred: {0}", e.ToString()); } client.Dispose(); log.Trace("(-):{0}", res); return(res); }