Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't exit server if TLS handshake fails #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/Test/Fake/HTTPD.pm
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ sub run {
$self->port || '<default>',
$@ eq '' ? '' : ": $@")) unless $d;

$d->accept; # wait for port check from parent process

while (my $c = $d->accept) {
while (1) {
# accept can return undef if TLS handshake fails (e.g., port test or client rejects
# cert).
my $c = $d->accept or next;
while (my $req = $c->get_request) {
my $res = $self->_to_http_res($app->($req));
$c->send_response($res);
Expand Down
14 changes: 14 additions & 0 deletions t/11_https.t
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ describe 'run_https_server' => sub {
is $res->header('Content-Type') => 'text/plain';
is $res->content => 'Hello World';
};

it 'aborted TLS handshake does not break server' => sub {
my $ua = LWP::UserAgent->new;
my $res = $ua->get($httpd->endpoint);
is $res->code => 500;
$ua = LWP::UserAgent->new(ssl_opts => {
SSL_verify_mode => 0,
verify_hostname => 0,
});
$res = $ua->get($httpd->endpoint);
is $res->code => 200;
is $res->header('Content-Type') => 'text/plain';
is $res->content => 'Hello World';
};
};

done_testing;
Loading