TLSProxy/Proxy.pm: refine NewSessionTicket detection.
authorAndy Polyakov <appro@openssl.org>
Mon, 16 Apr 2018 12:13:07 +0000 (14:13 +0200)
committerAndy Polyakov <appro@openssl.org>
Wed, 18 Apr 2018 17:56:53 +0000 (19:56 +0200)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5975)

util/perl/TLSProxy/Proxy.pm

index 9e9764d..df17731 100644 (file)
@@ -369,13 +369,14 @@ sub clientstart
     $fdset = IO::Select->new($server_sock, $client_sock);
     my @ready;
     my $ctr = 0;
-    my $sessionfile = $self->{sessionfile};
     local $SIG{PIPE} = "IGNORE";
+    $self->{saw_session_ticket} = undef;
     while($fdset->count && $ctr < 10) {
-        if (defined($sessionfile)) {
+        if (defined($self->{sessionfile})) {
             # s_client got -ign_eof and won't be exiting voluntarily, so we
-            # look for data *and* check on session file...
-            last if TLSProxy::Message->success() && -s $sessionfile;
+            # look for data *and* session ticket...
+            last if TLSProxy::Message->success()
+                    && $self->{saw_session_ticket};
         }
         if (!(@ready = $fdset->can_read(1))) {
             $ctr++;
@@ -449,7 +450,7 @@ sub clientstart
         $self->connect_to_server();
     }
     $pid = $self->{clientpid};
-    print "Waiting for client process to close: $pid...\n";
+    print "Waiting for s_client process to close: $pid...\n";
     waitpid($pid, 0);
 
     return 1;
@@ -496,6 +497,14 @@ sub process_packet
         $self->filter->($self);
     }
 
+    #Take a note on NewSessionTicket
+    foreach my $message (reverse @{$self->{message_list}}) {
+        if ($message->{mt} == TLSProxy::Message::MT_NEW_SESSION_TICKET) {
+            $self->{saw_session_ticket} = 1;
+            last;
+        }
+    }
+
     #Reconstruct the packet
     $packet = "";
     foreach my $record (@{$self->record_list}) {