7 use Symbol qw( gensym );
13 plan skip_all => 'pipes not properly supported on Windows' if 1;
21 Net::SSLeay::randomize();
22 Net::SSLeay::load_error_strings();
23 Net::SSLeay::OpenSSL_add_ssl_algorithms();
25 my $cert = File::Spec->catfile(qw( t data cert.pem ));
26 my $key = File::Spec->catfile(qw( t data key.pem ));
28 my $how_much = 1024 ** 2;
35 pipe $rs, $wc or die "pipe 1 ($!)";
36 pipe $rc, $ws or die "pipe 2 ($!)";
38 for my $h ($rs, $ws, $rc, $wc) {
39 my $old_select = select $h;
45 die unless defined $pid;
48 my $ctx = Net::SSLeay::CTX_new();
49 Net::SSLeay::set_server_cert_and_key($ctx, $cert, $key);
51 my $ssl = Net::SSLeay::new($ctx);
53 ok( Net::SSLeay::set_rfd($ssl, fileno($rs)), 'set_rfd using fileno' );
54 ok( Net::SSLeay::set_wfd($ssl, fileno($ws)), 'set_wfd using fileno' );
56 ok( Net::SSLeay::accept($ssl), 'accept' );
58 ok( my $got = Net::SSLeay::ssl_read_all($ssl, $how_much), 'ssl_read_all' );
60 is( Net::SSLeay::ssl_write_all($ssl, \$got), length $got, 'ssl_write_all' );
62 Net::SSLeay::free($ssl);
63 Net::SSLeay::CTX_free($ctx);
72 my $ctx = Net::SSLeay::CTX_new();
73 my $ssl = Net::SSLeay::new($ctx);
75 my $rc_handle = IO::Handle->new_from_fd( fileno($rc), 'r' );
76 my $wc_handle = IO::Handle->new_from_fd( fileno($wc), 'w' );
77 push @results, [ Net::SSLeay::set_rfd($ssl, $rc_handle), 'set_rfd using an io handle' ];
78 push @results, [ Net::SSLeay::set_wfd($ssl, $wc_handle), 'set_wfd using an io handle' ];
80 push @results, [ Net::SSLeay::connect($ssl), 'connect' ];
82 my $data = 'B' x $how_much;
84 push @results, [ Net::SSLeay::ssl_write_all($ssl, \$data) == length $data, 'ssl_write_all' ];
86 my $got = Net::SSLeay::ssl_read_all($ssl, $how_much);
87 push @results, [ $got eq $data, 'ssl_read_all' ];
89 Net::SSLeay::free($ssl);
90 Net::SSLeay::CTX_free($ctx);
97 push @results, [ $? == 0, 'server exited with 0' ];
99 Test::More->builder->current_test(5);
100 for my $t (@results) {
101 ok( $t->[0], $t->[1] );