diff --git a/test/recipes/70-test_sslcertstatus.t b/test/recipes/70-test_sslcertstatus.t index 9eb5116e7cf1ecf6f9974a335a28ff6f0ba44f3d..f700f92885b58ddf9e6d7ffe6721912bad4d41dd 100755 --- a/test/recipes/70-test_sslcertstatus.t +++ b/test/recipes/70-test_sslcertstatus.t @@ -37,12 +37,11 @@ my $proxy = TLSProxy::Proxy->new( (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE}) ); -plan tests => 1; - -#Test 1: Sending a status_request extension in both ClientHello and ServerHello -#but then omitting the CertificateStatus message is valid +#Test 1: Sending a status_request extension in both ClientHello and +#ServerHello but then omitting the CertificateStatus message is valid $proxy->clientflags("-status"); -$proxy->start(); +$proxy->start() or plan skip_all => "Unable to start up Proxy for tests"; +plan tests => 1; ok(TLSProxy::Message->success, "Missing CertificateStatus message"); sub certstatus_filter diff --git a/test/recipes/70-test_sslextension.t b/test/recipes/70-test_sslextension.t index 1084c9674d110ec5218a7a9d8616319778f811b9..7f69f649b3d3f386e710dba3523dfd10f6c4cdb7 100755 --- a/test/recipes/70-test_sslextension.t +++ b/test/recipes/70-test_sslextension.t @@ -34,10 +34,9 @@ my $proxy = TLSProxy::Proxy->new( (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE}) ); -plan tests => 3; - # Test 1: Sending a zero length extension block should pass -$proxy->start(); +$proxy->start() or plan skip_all => "Unable to start up Proxy for tests"; +plan tests => 3; ok(TLSProxy::Message->success, "Zero extension length test"); sub extension_filter @@ -111,4 +110,3 @@ $proxy->clear(); $proxy->filter(\&inject_duplicate_extension_serverhello); $proxy->start(); ok(TLSProxy::Message->fail(), "Duplicate ServerHello extension"); - diff --git a/test/recipes/70-test_sslrecords.t b/test/recipes/70-test_sslrecords.t index beacc4ad9adb830f77290b7ea620d1ec90e62170..b0e37398fba542469fbcbfa1fd256817ccfe7fbb 100644 --- a/test/recipes/70-test_sslrecords.t +++ b/test/recipes/70-test_sslrecords.t @@ -34,12 +34,11 @@ my $proxy = TLSProxy::Proxy->new( (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE}) ); -plan tests => 3; - #Test 1: Injecting out of context empty records should fail my $content_type = TLSProxy::Record::RT_APPLICATION_DATA; my $inject_recs_num = 1; -$proxy->start(); +$proxy->start() or plan skip_all => "Unable to start up Proxy for tests"; +plan tests => 3; ok(TLSProxy::Message->fail(), "Out of context empty records test"); #Test 2: Injecting in context empty records should succeed diff --git a/test/recipes/70-test_sslsessiontick.t b/test/recipes/70-test_sslsessiontick.t index aeed99c6b6f9b9bd8bee2777cd4c32113ecbedf0..89ef12f75bc45b8a905960528befdfea01a143ea 100755 --- a/test/recipes/70-test_sslsessiontick.t +++ b/test/recipes/70-test_sslsessiontick.t @@ -45,12 +45,11 @@ my $proxy = TLSProxy::Proxy->new( (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE}) ); -plan tests => 10; - #Test 1: By default with no existing session we should get a session ticket #Expected result: ClientHello extension seen; ServerHello extension seen # NewSessionTicket message seen; Full handshake -$proxy->start(); +$proxy->start() or plan skip_all => "Unable to start up Proxy for tests"; +plan tests => 10; checkmessages(1, "Default session ticket test", 1, 1, 1, 1); #Test 2: If the server does not accept tickets we should get a normal handshake diff --git a/test/recipes/70-test_sslskewith0p.t b/test/recipes/70-test_sslskewith0p.t index ca8dfe768190476c2275252764517bedd8f85ae4..bfdee8b739c9412c6030b07d036119d32e183a22 100755 --- a/test/recipes/70-test_sslskewith0p.t +++ b/test/recipes/70-test_sslskewith0p.t @@ -37,13 +37,12 @@ my $proxy = TLSProxy::Proxy->new( (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE}) ); -plan tests => 1; - #We must use an anon DHE cipher for this test $proxy->cipherc('ADH-AES128-SHA:@SECLEVEL=0'); $proxy->ciphers('ADH-AES128-SHA:@SECLEVEL=0'); -$proxy->start(); +$proxy->start() or plan skip_all => "Unable to start up Proxy for tests"; +plan tests => 1; ok(TLSProxy::Message->fail, "ServerKeyExchange with 0 p"); sub ske_0_p_filter diff --git a/test/recipes/70-test_sslvertol.t b/test/recipes/70-test_sslvertol.t index af82a8c1210a3b4d3502b51f64b1e6275a419bb6..f8c94e91dfa1fd2174aea73d8e577b6dcb175c81 100755 --- a/test/recipes/70-test_sslvertol.t +++ b/test/recipes/70-test_sslvertol.t @@ -34,11 +34,10 @@ my $proxy = TLSProxy::Proxy->new( (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE}) ); -plan tests => 2; - #Test 1: Asking for TLS1.3 should pass my $client_version = TLSProxy::Record::VERS_TLS_1_3; -$proxy->start(); +$proxy->start() or plan skip_all => "Unable to start up Proxy for tests"; +plan tests => 2; ok(TLSProxy::Message->success(), "Version tolerance test, TLS 1.3"); #Test 2: Testing something below SSLv3 should fail diff --git a/test/recipes/70-test_tlsextms.t b/test/recipes/70-test_tlsextms.t index 25cc62738131f9aba03f2b6982555da37f74c6e8..1248594c068331fa71e324c534c6a9092aeb4aa3 100644 --- a/test/recipes/70-test_tlsextms.t +++ b/test/recipes/70-test_tlsextms.t @@ -46,15 +46,14 @@ my $proxy = TLSProxy::Proxy->new( (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE}) ); -plan tests => 9; - #Test 1: By default server and client should send extended master secret # extension. #Expected result: ClientHello extension seen; ServerHello extension seen # Full handshake setrmextms(0, 0); -$proxy->start(); +$proxy->start() or plan skip_all => "Unable to start up Proxy for tests"; +plan tests => 9; checkmessages(1, "Default extended master secret test", 1, 1, 1); #Test 2: If client omits extended master secret extension, server should too. diff --git a/test/recipes/90-test_networking.t b/test/recipes/90-test_networking.t deleted file mode 100644 index 4f984cb908bcf6645a6c0a4c0eb657baa5b4958a..0000000000000000000000000000000000000000 --- a/test/recipes/90-test_networking.t +++ /dev/null @@ -1,67 +0,0 @@ -#! /usr/bin/env perl -# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. -# -# Licensed under the OpenSSL license (the "License"). You may not use -# this file except in compliance with the License. You can obtain a copy -# in the file LICENSE in the source distribution or at -# https://www.openssl.org/source/license.html - -use strict; -use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_file bldtop_dir/; -use OpenSSL::Test::Utils; -use TLSProxy::Proxy; - -my $test_name = "test_networking"; -setup($test_name); - -plan skip_all => "TLSProxy isn't usable on $^O" - if $^O =~ /^(VMS|MSWin32)$/; - -plan skip_all => "$test_name needs the dynamic engine feature enabled" - if disabled("engine") || disabled("dynamic-engine"); - -plan skip_all => "$test_name needs the sock feature enabled" - if disabled("sock"); - -$ENV{OPENSSL_ia32cap} = '~0x200000200000000'; - -my $proxy = TLSProxy::Proxy->new( - undef, - cmdstr(app(["openssl"]), display => 1), - srctop_file("apps", "server.pem"), - (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE}) -); - -plan tests => 2; - -#Test 1: Try IPv4 -$proxy->clear(); -$proxy->serverflags("-4"); -$proxy->clientflags("-4"); -$proxy->server_addr("127.0.0.1"); -$proxy->proxy_addr("127.0.0.1"); -ok(check_connection(), "Trying IPv4"); - - SKIP: { - skip "No IPv6 support", 1 unless $proxy->supports_IPv6(); - - #Test 2: Try IPv6 - $proxy->clear(); - $proxy->serverflags("-6"); - $proxy->clientflags("-6"); - $proxy->server_addr("[::1]"); - $proxy->proxy_addr("[::1]"); - ok(check_connection(), "Trying IPv6"); -} - -sub check_connection -{ - eval { $proxy->start(); }; - - if ($@ ne "") { - print STDERR "Proxy connection failed: $@\n"; - return 0; - } - - 1; -} diff --git a/util/TLSProxy/Proxy.pm b/util/TLSProxy/Proxy.pm index 3b03ea9eeb2d2118b4e0de0488d86f2043e13a7d..e0ce43aa7793f647bd964546645b1d97f0d2aa2b 100644 --- a/util/TLSProxy/Proxy.pm +++ b/util/TLSProxy/Proxy.pm @@ -161,7 +161,7 @@ sub start } $self->serverpid($pid); - $self->clientstart; + return $self->clientstart; } sub clientstart @@ -188,7 +188,8 @@ sub clientstart if ($proxy_sock) { print "Proxy started on port ".$self->proxy_port."\n"; } else { - die "Failed creating proxy socket (".$proxaddr.",".$self->proxy_port."): $!\n"; + warn "Failed creating proxy socket (".$proxaddr.",".$self->proxy_port."): $!\n"; + return 0; } if ($self->execute) { @@ -213,8 +214,11 @@ sub clientstart } # Wait for incoming connection from client - my $client_sock = $proxy_sock->accept() - or die "Failed accepting incoming connection: $!\n"; + my $client_sock; + if(!($client_sock = $proxy_sock->accept())) { + warn "Failed accepting incoming connection: $!\n"; + return 0; + } print "Connection opened\n"; @@ -245,7 +249,8 @@ sub clientstart #Sleep for a short while select(undef, undef, undef, 0.1); } else { - die "Failed to start up server (".$servaddr.",".$self->server_port."): $!\n"; + warn "Failed to start up server (".$servaddr.",".$self->server_port."): $!\n"; + return 0; } } } while (!$server_sock); @@ -295,6 +300,7 @@ sub clientstart .$self->serverpid."\n"; waitpid( $self->serverpid, 0); } + return 1; } sub process_packet