Beispiel #1
0
			public void AdvancedServerTest() {
				serverRemoteCertificateValidationCallback = new RemoteCertificateValidationHandler(ValidateRemoteCert);

				try {
					testName = "AdvancedServerTest";
					AcceptConnection(); // sets the client member
					sslStream = new SslStream(client.GetStream(), false, serverRemoteCertificateValidationCallback);
					sslStream.AuthenticateAsServer(testServer.serverCertificate, true, testServer.serverCAChain, SslProtocols.Tls, SslStrength.All, true);

					// Verify mutual authentication
					if (!sslStream.IsMutuallyAuthenticated) {
						Console.WriteLine("{0} failed - stream is not mutually authenticated", testName);
						Shutdown(false);
						return;
					}

					// Verify protocol
					if (sslStream.SslProtocol != SslProtocols.Tls) {
						Console.WriteLine("{0} failed - negotiated non Tls connection", testName);
						Shutdown(false);
						return;
					}
					// Verify cipher strength
					if (sslStream.CipherStrength < 256) {
						Console.WriteLine("{0} failed - negotiated less than 256bit cipher", testName);
						Shutdown(false);
						return;
					}
					// Do the server read, and write of the messages
					if (DoServerReadWrite()) {
						Shutdown(true);
					}
					else {
						Shutdown(false);
					}
				}
				catch (Exception) {
					Shutdown(false);
				}
			}
Beispiel #2
0
			public void BasicServerTest() {
				try {
					testName = "BasicServerTest";
					AcceptConnection(); // sets the client member
					sslStream = new SslStream(client.GetStream(), false);
					sslStream.AuthenticateAsServer(testServer.serverCertificate);
					// Do the server read, and write of the messages
					if (DoServerReadWrite()) {
						Shutdown(true);
					}
					else {
						Shutdown(false);
					}
				}
				catch (Exception) {
					Shutdown(false);
				}
			}
Beispiel #3
0
			public void IntermediateServerTest() {
				try {
					testName = "IntermediateServerTest";
					AcceptConnection(); // sets the client member
					sslStream = new SslStream(client.GetStream(), false);
					sslStream.AuthenticateAsServer(testServer.serverCertificate, false, null, SslProtocols.Tls, SslStrength.All, false);

					// Verify protocol
					if (sslStream.SslProtocol != SslProtocols.Tls) {
						Console.WriteLine("{0} failed - negotiated non Tls connection", testName);
						Shutdown(false);
						return;
					}
					// Verify cipher strength
					if (sslStream.CipherStrength < 256) {
						Console.WriteLine("{0} failed - negotiated less than 256bit cipher", testName);
						Shutdown(false);
						return;
					}
					//Verify cipher
					if (sslStream.CipherAlgorithm != CipherAlgorithmType.Aes256) {
						Console.WriteLine("{0} failed - negotiated cipher was not AES256", testName);
						Shutdown(false);
						return;
					}

					// Do the server read, and write of the messages
					if (DoServerReadWrite()) {
						Shutdown(true);
					}
					else {
						Shutdown(false);
					}
				}
				catch (Exception) {
					Shutdown(false);
				}
			}