2016-04-20 14:20:59 +00:00
|
|
|
# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
2015-06-16 12:06:41 +00:00
|
|
|
#
|
2016-04-20 14:20:59 +00:00
|
|
|
# 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
|
2015-06-16 12:06:41 +00:00
|
|
|
|
|
|
|
use strict;
|
2016-03-15 16:44:26 +00:00
|
|
|
use POSIX ":sys_wait_h";
|
2015-06-16 12:06:41 +00:00
|
|
|
|
|
|
|
package TLSProxy::Proxy;
|
|
|
|
|
|
|
|
use File::Spec;
|
|
|
|
use IO::Socket;
|
|
|
|
use IO::Select;
|
|
|
|
use TLSProxy::Record;
|
|
|
|
use TLSProxy::Message;
|
|
|
|
use TLSProxy::ClientHello;
|
2017-02-02 16:06:28 +00:00
|
|
|
use TLSProxy::HelloRetryRequest;
|
2015-08-07 13:38:21 +00:00
|
|
|
use TLSProxy::ServerHello;
|
2016-11-28 22:39:23 +00:00
|
|
|
use TLSProxy::EncryptedExtensions;
|
2016-12-02 09:14:15 +00:00
|
|
|
use TLSProxy::Certificate;
|
2017-01-05 12:28:40 +00:00
|
|
|
use TLSProxy::CertificateVerify;
|
2015-08-07 13:38:21 +00:00
|
|
|
use TLSProxy::ServerKeyExchange;
|
2015-09-15 10:06:12 +00:00
|
|
|
use TLSProxy::NewSessionTicket;
|
2015-06-16 12:06:41 +00:00
|
|
|
|
2016-02-02 23:57:30 +00:00
|
|
|
my $have_IPv6 = 0;
|
|
|
|
my $IP_factory;
|
|
|
|
|
2016-11-15 11:09:25 +00:00
|
|
|
my $is_tls13 = 0;
|
2016-12-28 15:01:57 +00:00
|
|
|
my $ciphersuite = undef;
|
2016-11-15 11:09:25 +00:00
|
|
|
|
2015-06-16 12:06:41 +00:00
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my $class = shift;
|
|
|
|
my ($filter,
|
|
|
|
$execute,
|
|
|
|
$cert,
|
|
|
|
$debug) = @_;
|
|
|
|
|
|
|
|
my $self = {
|
|
|
|
#Public read/write
|
|
|
|
proxy_addr => "localhost",
|
|
|
|
proxy_port => 4453,
|
|
|
|
server_addr => "localhost",
|
|
|
|
server_port => 4443,
|
|
|
|
filter => $filter,
|
2015-08-13 14:17:14 +00:00
|
|
|
serverflags => "",
|
|
|
|
clientflags => "",
|
|
|
|
serverconnects => 1,
|
2016-03-15 16:44:26 +00:00
|
|
|
serverpid => 0,
|
2016-11-22 13:43:50 +00:00
|
|
|
reneg => 0,
|
2017-01-20 12:08:51 +00:00
|
|
|
sessionfile => undef,
|
2015-06-16 12:06:41 +00:00
|
|
|
|
|
|
|
#Public read
|
|
|
|
execute => $execute,
|
|
|
|
cert => $cert,
|
|
|
|
debug => $debug,
|
2015-08-13 14:17:14 +00:00
|
|
|
cipherc => "",
|
2016-10-28 14:57:12 +00:00
|
|
|
ciphers => "AES128-SHA:TLS13-AES-128-GCM-SHA256",
|
2015-06-16 12:06:41 +00:00
|
|
|
flight => 0,
|
|
|
|
record_list => [],
|
|
|
|
message_list => [],
|
|
|
|
};
|
|
|
|
|
2016-02-14 06:10:38 +00:00
|
|
|
# IO::Socket::IP is on the core module list, IO::Socket::INET6 isn't.
|
|
|
|
# However, IO::Socket::INET6 is older and is said to be more widely
|
|
|
|
# deployed for the moment, and may have less bugs, so we try the latter
|
|
|
|
# first, then fall back on the code modules. Worst case scenario, we
|
|
|
|
# fall back to IO::Socket::INET, only supports IPv4.
|
2016-02-02 23:57:30 +00:00
|
|
|
eval {
|
2016-02-14 06:10:38 +00:00
|
|
|
require IO::Socket::INET6;
|
|
|
|
my $s = IO::Socket::INET6->new(
|
2016-02-02 23:57:30 +00:00
|
|
|
LocalAddr => "::1",
|
|
|
|
LocalPort => 0,
|
|
|
|
Listen=>1,
|
|
|
|
);
|
|
|
|
$s or die "\n";
|
|
|
|
$s->close();
|
|
|
|
};
|
|
|
|
if ($@ eq "") {
|
2016-02-14 06:10:38 +00:00
|
|
|
$IP_factory = sub { IO::Socket::INET6->new(@_); };
|
2016-02-02 23:57:30 +00:00
|
|
|
$have_IPv6 = 1;
|
|
|
|
} else {
|
|
|
|
eval {
|
2016-02-14 06:10:38 +00:00
|
|
|
require IO::Socket::IP;
|
|
|
|
my $s = IO::Socket::IP->new(
|
2016-02-02 23:57:30 +00:00
|
|
|
LocalAddr => "::1",
|
|
|
|
LocalPort => 0,
|
|
|
|
Listen=>1,
|
|
|
|
);
|
|
|
|
$s or die "\n";
|
|
|
|
$s->close();
|
|
|
|
};
|
|
|
|
if ($@ eq "") {
|
2016-02-14 06:10:38 +00:00
|
|
|
$IP_factory = sub { IO::Socket::IP->new(@_); };
|
2016-02-02 23:57:30 +00:00
|
|
|
$have_IPv6 = 1;
|
|
|
|
} else {
|
|
|
|
$IP_factory = sub { IO::Socket::INET->new(@_); };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-16 12:06:41 +00:00
|
|
|
return bless $self, $class;
|
|
|
|
}
|
|
|
|
|
2016-03-15 16:44:26 +00:00
|
|
|
sub clearClient
|
2015-06-16 12:06:41 +00:00
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
2015-08-13 14:17:14 +00:00
|
|
|
$self->{cipherc} = "";
|
2015-06-16 12:06:41 +00:00
|
|
|
$self->{flight} = 0;
|
|
|
|
$self->{record_list} = [];
|
|
|
|
$self->{message_list} = [];
|
2015-08-13 14:17:14 +00:00
|
|
|
$self->{clientflags} = "";
|
2017-01-20 12:08:51 +00:00
|
|
|
$self->{sessionfile} = undef;
|
2016-11-15 11:09:25 +00:00
|
|
|
$is_tls13 = 0;
|
2016-12-28 15:01:57 +00:00
|
|
|
$ciphersuite = undef;
|
2015-06-16 12:06:41 +00:00
|
|
|
|
|
|
|
TLSProxy::Message->clear();
|
|
|
|
TLSProxy::Record->clear();
|
|
|
|
}
|
|
|
|
|
2016-03-15 16:44:26 +00:00
|
|
|
sub clear
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
$self->clearClient;
|
2016-10-28 14:57:12 +00:00
|
|
|
$self->{ciphers} = "AES128-SHA:TLS13-AES-128-GCM-SHA256";
|
2016-03-15 16:44:26 +00:00
|
|
|
$self->{serverflags} = "";
|
|
|
|
$self->{serverconnects} = 1;
|
|
|
|
$self->{serverpid} = 0;
|
2016-11-22 13:43:50 +00:00
|
|
|
$self->{reneg} = 0;
|
2016-03-15 16:44:26 +00:00
|
|
|
}
|
|
|
|
|
2015-06-16 12:06:41 +00:00
|
|
|
sub restart
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
$self->clear;
|
|
|
|
$self->start;
|
|
|
|
}
|
|
|
|
|
2015-08-13 14:17:14 +00:00
|
|
|
sub clientrestart
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
$self->clear;
|
|
|
|
$self->clientstart;
|
|
|
|
}
|
|
|
|
|
2015-06-16 12:06:41 +00:00
|
|
|
sub start
|
|
|
|
{
|
|
|
|
my ($self) = shift;
|
|
|
|
my $pid;
|
|
|
|
|
|
|
|
$pid = fork();
|
|
|
|
if ($pid == 0) {
|
2016-02-17 21:04:54 +00:00
|
|
|
if (!$self->debug) {
|
|
|
|
open(STDOUT, ">", File::Spec->devnull())
|
|
|
|
or die "Failed to redirect stdout: $!";
|
|
|
|
open(STDERR, ">&STDOUT");
|
|
|
|
}
|
2015-09-19 19:07:33 +00:00
|
|
|
my $execcmd = $self->execute
|
2016-10-28 14:57:12 +00:00
|
|
|
." s_server -no_comp -rev -engine ossltest -accept "
|
2015-08-07 13:38:21 +00:00
|
|
|
.($self->server_port)
|
2016-11-28 22:39:23 +00:00
|
|
|
." -cert ".$self->cert." -cert2 ".$self->cert
|
|
|
|
." -naccept ".$self->serverconnects;
|
2015-08-07 13:38:21 +00:00
|
|
|
if ($self->ciphers ne "") {
|
|
|
|
$execcmd .= " -cipher ".$self->ciphers;
|
|
|
|
}
|
2015-08-13 14:17:14 +00:00
|
|
|
if ($self->serverflags ne "") {
|
|
|
|
$execcmd .= " ".$self->serverflags;
|
|
|
|
}
|
2015-08-07 13:38:21 +00:00
|
|
|
exec($execcmd);
|
2015-06-16 12:06:41 +00:00
|
|
|
}
|
2016-03-15 16:44:26 +00:00
|
|
|
$self->serverpid($pid);
|
2015-06-16 12:06:41 +00:00
|
|
|
|
2016-06-14 13:35:26 +00:00
|
|
|
return $self->clientstart;
|
2015-08-13 14:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub clientstart
|
|
|
|
{
|
|
|
|
my ($self) = shift;
|
2015-06-16 12:06:41 +00:00
|
|
|
my $oldstdout;
|
|
|
|
|
|
|
|
if(!$self->debug) {
|
2015-08-13 17:14:34 +00:00
|
|
|
open DEVNULL, ">", File::Spec->devnull();
|
|
|
|
$oldstdout = select(DEVNULL);
|
2015-06-16 12:06:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Create the Proxy socket
|
2016-02-03 20:43:43 +00:00
|
|
|
my $proxaddr = $self->proxy_addr;
|
2016-02-02 23:57:30 +00:00
|
|
|
$proxaddr =~ s/[\[\]]//g; # Remove [ and ]
|
|
|
|
my $proxy_sock = $IP_factory->(
|
|
|
|
LocalHost => $proxaddr,
|
2015-06-16 12:06:41 +00:00
|
|
|
LocalPort => $self->proxy_port,
|
|
|
|
Proto => "tcp",
|
|
|
|
Listen => SOMAXCONN,
|
2015-12-26 22:42:11 +00:00
|
|
|
ReuseAddr => 1
|
2015-06-16 12:06:41 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
if ($proxy_sock) {
|
|
|
|
print "Proxy started on port ".$self->proxy_port."\n";
|
|
|
|
} else {
|
2016-06-14 13:35:26 +00:00
|
|
|
warn "Failed creating proxy socket (".$proxaddr.",".$self->proxy_port."): $!\n";
|
|
|
|
return 0;
|
2015-06-16 12:06:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($self->execute) {
|
|
|
|
my $pid = fork();
|
|
|
|
if ($pid == 0) {
|
2016-02-17 21:04:54 +00:00
|
|
|
if (!$self->debug) {
|
|
|
|
open(STDOUT, ">", File::Spec->devnull())
|
|
|
|
or die "Failed to redirect stdout: $!";
|
|
|
|
open(STDERR, ">&STDOUT");
|
|
|
|
}
|
2016-11-22 13:43:50 +00:00
|
|
|
my $echostr;
|
|
|
|
if ($self->reneg()) {
|
|
|
|
$echostr = "R";
|
|
|
|
} else {
|
|
|
|
$echostr = "test";
|
|
|
|
}
|
|
|
|
my $execcmd = "echo ".$echostr." | ".$self->execute
|
2015-08-10 09:46:27 +00:00
|
|
|
." s_client -engine ossltest -connect "
|
2015-08-07 13:38:21 +00:00
|
|
|
.($self->proxy_addr).":".($self->proxy_port);
|
|
|
|
if ($self->cipherc ne "") {
|
|
|
|
$execcmd .= " -cipher ".$self->cipherc;
|
|
|
|
}
|
2015-08-13 14:17:14 +00:00
|
|
|
if ($self->clientflags ne "") {
|
|
|
|
$execcmd .= " ".$self->clientflags;
|
|
|
|
}
|
2017-01-20 12:08:51 +00:00
|
|
|
if (defined $self->sessionfile) {
|
|
|
|
$execcmd .= " -ign_eof";
|
|
|
|
}
|
2015-08-07 13:38:21 +00:00
|
|
|
exec($execcmd);
|
2015-06-16 12:06:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Wait for incoming connection from client
|
2016-06-14 13:35:26 +00:00
|
|
|
my $client_sock;
|
|
|
|
if(!($client_sock = $proxy_sock->accept())) {
|
|
|
|
warn "Failed accepting incoming connection: $!\n";
|
|
|
|
return 0;
|
|
|
|
}
|
2015-06-16 12:06:41 +00:00
|
|
|
|
|
|
|
print "Connection opened\n";
|
|
|
|
|
|
|
|
# Now connect to the server
|
|
|
|
my $retry = 3;
|
|
|
|
my $server_sock;
|
|
|
|
#We loop over this a few times because sometimes s_server can take a while
|
|
|
|
#to start up
|
|
|
|
do {
|
2016-02-02 23:57:30 +00:00
|
|
|
my $servaddr = $self->server_addr;
|
|
|
|
$servaddr =~ s/[\[\]]//g; # Remove [ and ]
|
2016-05-11 22:01:41 +00:00
|
|
|
eval {
|
|
|
|
$server_sock = $IP_factory->(
|
|
|
|
PeerAddr => $servaddr,
|
|
|
|
PeerPort => $self->server_port,
|
|
|
|
MultiHomed => 1,
|
|
|
|
Proto => 'tcp'
|
|
|
|
);
|
|
|
|
};
|
2015-06-16 12:06:41 +00:00
|
|
|
|
|
|
|
$retry--;
|
2016-05-16 15:54:28 +00:00
|
|
|
#Some buggy IP factories can return a defined server_sock that hasn't
|
|
|
|
#actually connected, so we check peerport too
|
|
|
|
if ($@ || !defined($server_sock) || !defined($server_sock->peerport)) {
|
2016-02-20 23:17:28 +00:00
|
|
|
$server_sock->close() if defined($server_sock);
|
|
|
|
undef $server_sock;
|
2015-06-16 12:06:41 +00:00
|
|
|
if ($retry) {
|
|
|
|
#Sleep for a short while
|
|
|
|
select(undef, undef, undef, 0.1);
|
|
|
|
} else {
|
2016-06-14 13:35:26 +00:00
|
|
|
warn "Failed to start up server (".$servaddr.",".$self->server_port."): $!\n";
|
|
|
|
return 0;
|
2015-06-16 12:06:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (!$server_sock);
|
|
|
|
|
|
|
|
my $sel = IO::Select->new($server_sock, $client_sock);
|
|
|
|
my $indata;
|
|
|
|
my @handles = ($server_sock, $client_sock);
|
|
|
|
|
|
|
|
#Wait for either the server socket or the client socket to become readable
|
|
|
|
my @ready;
|
|
|
|
while(!(TLSProxy::Message->end) && (@ready = $sel->can_read)) {
|
|
|
|
foreach my $hand (@ready) {
|
|
|
|
if ($hand == $server_sock) {
|
|
|
|
$server_sock->sysread($indata, 16384) or goto END;
|
|
|
|
$indata = $self->process_packet(1, $indata);
|
|
|
|
$client_sock->syswrite($indata);
|
|
|
|
} elsif ($hand == $client_sock) {
|
|
|
|
$client_sock->sysread($indata, 16384) or goto END;
|
|
|
|
$indata = $self->process_packet(0, $indata);
|
|
|
|
$server_sock->syswrite($indata);
|
|
|
|
} else {
|
|
|
|
print "Err\n";
|
|
|
|
goto END;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-20 12:08:51 +00:00
|
|
|
for (my $ctr = 0;
|
|
|
|
defined $self->sessionfile()
|
|
|
|
&& (!(-f $self->sessionfile()) || $ctr == 3);
|
|
|
|
$ctr++) {
|
|
|
|
sleep 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
die "Session file not created"
|
|
|
|
if (defined $self->sessionfile() && !(-f $self->sessionfile()));
|
|
|
|
|
2015-06-16 12:06:41 +00:00
|
|
|
END:
|
|
|
|
print "Connection closed\n";
|
|
|
|
if($server_sock) {
|
|
|
|
$server_sock->close();
|
|
|
|
}
|
|
|
|
if($client_sock) {
|
|
|
|
#Closing this also kills the child process
|
|
|
|
$client_sock->close();
|
|
|
|
}
|
|
|
|
if($proxy_sock) {
|
|
|
|
$proxy_sock->close();
|
|
|
|
}
|
|
|
|
if(!$self->debug) {
|
|
|
|
select($oldstdout);
|
|
|
|
}
|
2016-03-15 16:44:26 +00:00
|
|
|
$self->serverconnects($self->serverconnects - 1);
|
|
|
|
if ($self->serverconnects == 0) {
|
|
|
|
die "serverpid is zero\n" if $self->serverpid == 0;
|
|
|
|
print "Waiting for server process to close: "
|
|
|
|
.$self->serverpid."\n";
|
|
|
|
waitpid( $self->serverpid, 0);
|
2017-01-10 08:22:05 +00:00
|
|
|
die "exit code $? from server process\n" if $? != 0;
|
2016-03-15 16:44:26 +00:00
|
|
|
}
|
2016-06-14 13:35:26 +00:00
|
|
|
return 1;
|
2015-06-16 12:06:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub process_packet
|
|
|
|
{
|
|
|
|
my ($self, $server, $packet) = @_;
|
|
|
|
my $len_real;
|
|
|
|
my $decrypt_len;
|
|
|
|
my $data;
|
|
|
|
my $recnum;
|
|
|
|
|
|
|
|
if ($server) {
|
|
|
|
print "Received server packet\n";
|
|
|
|
} else {
|
|
|
|
print "Received client packet\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print "Packet length = ".length($packet)."\n";
|
|
|
|
print "Processing flight ".$self->flight."\n";
|
|
|
|
|
|
|
|
#Return contains the list of record found in the packet followed by the
|
|
|
|
#list of messages in those records
|
|
|
|
my @ret = TLSProxy::Record->get_records($server, $self->flight, $packet);
|
|
|
|
push @{$self->record_list}, @{$ret[0]};
|
|
|
|
push @{$self->{message_list}}, @{$ret[1]};
|
|
|
|
|
|
|
|
print "\n";
|
|
|
|
|
|
|
|
#Finished parsing. Call user provided filter here
|
2015-08-13 14:17:14 +00:00
|
|
|
if(defined $self->filter) {
|
|
|
|
$self->filter->($self);
|
|
|
|
}
|
2015-06-16 12:06:41 +00:00
|
|
|
|
|
|
|
#Reconstruct the packet
|
|
|
|
$packet = "";
|
|
|
|
foreach my $record (@{$self->record_list}) {
|
|
|
|
#We only replay the records for the current flight
|
|
|
|
if ($record->flight != $self->flight) {
|
|
|
|
next;
|
|
|
|
}
|
2016-11-18 23:44:09 +00:00
|
|
|
$packet .= $record->reconstruct_record($server);
|
2015-06-16 12:06:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$self->{flight} = $self->{flight} + 1;
|
|
|
|
|
|
|
|
print "Forwarded packet length = ".length($packet)."\n\n";
|
|
|
|
|
|
|
|
return $packet;
|
|
|
|
}
|
|
|
|
|
|
|
|
#Read accessors
|
|
|
|
sub execute
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
return $self->{execute};
|
|
|
|
}
|
|
|
|
sub cert
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
return $self->{cert};
|
|
|
|
}
|
|
|
|
sub debug
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
return $self->{debug};
|
|
|
|
}
|
|
|
|
sub flight
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
return $self->{flight};
|
|
|
|
}
|
|
|
|
sub record_list
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
return $self->{record_list};
|
|
|
|
}
|
|
|
|
sub success
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
return $self->{success};
|
|
|
|
}
|
|
|
|
sub end
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
return $self->{end};
|
|
|
|
}
|
2016-02-02 23:57:30 +00:00
|
|
|
sub supports_IPv6
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
return $have_IPv6;
|
|
|
|
}
|
2015-06-16 12:06:41 +00:00
|
|
|
|
|
|
|
#Read/write accessors
|
|
|
|
sub proxy_addr
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
2016-12-08 09:44:06 +00:00
|
|
|
$self->{proxy_addr} = shift;
|
2015-06-16 12:06:41 +00:00
|
|
|
}
|
|
|
|
return $self->{proxy_addr};
|
|
|
|
}
|
|
|
|
sub proxy_port
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
2016-12-08 09:44:06 +00:00
|
|
|
$self->{proxy_port} = shift;
|
2015-06-16 12:06:41 +00:00
|
|
|
}
|
|
|
|
return $self->{proxy_port};
|
|
|
|
}
|
|
|
|
sub server_addr
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
2016-12-08 09:44:06 +00:00
|
|
|
$self->{server_addr} = shift;
|
2015-06-16 12:06:41 +00:00
|
|
|
}
|
|
|
|
return $self->{server_addr};
|
|
|
|
}
|
|
|
|
sub server_port
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
2016-12-08 09:44:06 +00:00
|
|
|
$self->{server_port} = shift;
|
2015-06-16 12:06:41 +00:00
|
|
|
}
|
|
|
|
return $self->{server_port};
|
|
|
|
}
|
|
|
|
sub filter
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
2016-12-08 09:44:06 +00:00
|
|
|
$self->{filter} = shift;
|
2015-06-16 12:06:41 +00:00
|
|
|
}
|
|
|
|
return $self->{filter};
|
|
|
|
}
|
2015-08-07 13:38:21 +00:00
|
|
|
sub cipherc
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
2016-12-08 09:44:06 +00:00
|
|
|
$self->{cipherc} = shift;
|
2015-08-07 13:38:21 +00:00
|
|
|
}
|
|
|
|
return $self->{cipherc};
|
|
|
|
}
|
|
|
|
sub ciphers
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
2016-12-08 09:44:06 +00:00
|
|
|
$self->{ciphers} = shift;
|
2015-08-07 13:38:21 +00:00
|
|
|
}
|
|
|
|
return $self->{ciphers};
|
|
|
|
}
|
2015-08-13 14:17:14 +00:00
|
|
|
sub serverflags
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
2016-12-08 09:44:06 +00:00
|
|
|
$self->{serverflags} = shift;
|
2015-08-13 14:17:14 +00:00
|
|
|
}
|
|
|
|
return $self->{serverflags};
|
|
|
|
}
|
|
|
|
sub clientflags
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
2016-12-08 09:44:06 +00:00
|
|
|
$self->{clientflags} = shift;
|
2015-08-13 14:17:14 +00:00
|
|
|
}
|
|
|
|
return $self->{clientflags};
|
|
|
|
}
|
|
|
|
sub serverconnects
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
2016-12-08 09:44:06 +00:00
|
|
|
$self->{serverconnects} = shift;
|
2015-08-13 14:17:14 +00:00
|
|
|
}
|
|
|
|
return $self->{serverconnects};
|
|
|
|
}
|
2015-09-16 15:47:55 +00:00
|
|
|
# This is a bit ugly because the caller is responsible for keeping the records
|
|
|
|
# in sync with the updated message list; simply updating the message list isn't
|
|
|
|
# sufficient to get the proxy to forward the new message.
|
|
|
|
# But it does the trick for the one test (test_sslsessiontick) that needs it.
|
|
|
|
sub message_list
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
|
|
|
$self->{message_list} = shift;
|
|
|
|
}
|
|
|
|
return $self->{message_list};
|
|
|
|
}
|
2016-03-15 16:44:26 +00:00
|
|
|
sub serverpid
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
2016-12-08 09:44:06 +00:00
|
|
|
$self->{serverpid} = shift;
|
2016-03-15 16:44:26 +00:00
|
|
|
}
|
|
|
|
return $self->{serverpid};
|
|
|
|
}
|
2016-08-10 04:45:51 +00:00
|
|
|
|
|
|
|
sub fill_known_data
|
|
|
|
{
|
|
|
|
my $length = shift;
|
|
|
|
my $ret = "";
|
|
|
|
for (my $i = 0; $i < $length; $i++) {
|
|
|
|
$ret .= chr($i);
|
|
|
|
}
|
|
|
|
return $ret;
|
|
|
|
}
|
2016-11-22 13:43:50 +00:00
|
|
|
|
2016-11-15 11:09:25 +00:00
|
|
|
sub is_tls13
|
|
|
|
{
|
|
|
|
my $class = shift;
|
|
|
|
if (@_) {
|
2016-12-08 09:44:06 +00:00
|
|
|
$is_tls13 = shift;
|
2016-11-15 11:09:25 +00:00
|
|
|
}
|
|
|
|
return $is_tls13;
|
|
|
|
}
|
2016-11-22 13:43:50 +00:00
|
|
|
|
|
|
|
sub reneg
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
2016-12-08 09:44:06 +00:00
|
|
|
$self->{reneg} = shift;
|
2016-11-22 13:43:50 +00:00
|
|
|
}
|
|
|
|
return $self->{reneg};
|
|
|
|
}
|
|
|
|
|
2017-01-20 12:08:51 +00:00
|
|
|
#Setting a sessionfile means that the client will not close until the given
|
|
|
|
#file exists. This is useful in TLSv1.3 where otherwise s_client will close
|
|
|
|
#immediately at the end of the handshake, but before the session has been
|
|
|
|
#received from the server. A side effect of this is that s_client never sends
|
|
|
|
#a close_notify, so instead we consider success to be when it sends application
|
|
|
|
#data over the connection.
|
|
|
|
sub sessionfile
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
if (@_) {
|
|
|
|
$self->{sessionfile} = shift;
|
|
|
|
TLSProxy::Message->successondata(1);
|
|
|
|
}
|
|
|
|
return $self->{sessionfile};
|
|
|
|
}
|
|
|
|
|
2016-12-28 15:01:57 +00:00
|
|
|
sub ciphersuite
|
|
|
|
{
|
|
|
|
my $class = shift;
|
|
|
|
if (@_) {
|
|
|
|
$ciphersuite = shift;
|
|
|
|
}
|
|
|
|
return $ciphersuite;
|
|
|
|
}
|
|
|
|
|
2015-06-16 12:06:41 +00:00
|
|
|
1;
|