File Coverage

blib/lib/POE/Component/TLSify/ClientHandle.pm
Criterion Covered Total %
statement 26 28 92.8
branch 4 8 50.0
condition 4 9 44.4
subroutine 6 6 100.0
pod n/a
total 40 51 78.4


line stmt bran cond sub pod time code
1             package POE::Component::TLSify::ClientHandle;
2             $POE::Component::TLSify::ClientHandle::VERSION = '0.04';
3             #ABSTRACT: Client-side handle for TLSify
4              
5 11     11   78 use strict;
  11         28  
  11         326  
6 11     11   56 use warnings;
  11         23  
  11         304  
7 11     11   62 use POSIX qw[EAGAIN EWOULDBLOCK];
  11         22  
  11         85  
8 11     11   10794 use IO::Socket::SSL qw[$SSL_ERROR SSL_WANT_READ SSL_WANT_WRITE];
  11         668410  
  11         93  
9              
10 11     11   7436 use parent 'POE::Component::TLSify::ServerHandle';
  11         3346  
  11         75  
11              
12             sub TIEHANDLE {
13 18     18   78 my ($class,$socket,$args,$connref) = @_;
14 18         48 my $fileno = fileno($socket);
15              
16 18         65 my %SSL_ca_args = IO::Socket::SSL::default_ca();
17              
18 18 50 66     1778 if ( !defined $args->{SSL_verify_mode}
      33        
19             and !defined $args->{SSL_ca_file}
20             and !defined $args->{SSL_ca_path} ) {
21              
22 1 50       5 unless ( %SSL_ca_args ) {
23 0         0 $SSL_ca_args{SSL_verify_mode} = IO::Socket::SSL::SSL_VERIFY_NONE();
24             }
25              
26 1         5 %$args = ( %SSL_ca_args, %$args );
27             }
28              
29 18 50       149 $socket = IO::Socket::SSL->start_SSL(
30             $socket,
31             SSL_startHandshake => 0,
32             %$args,
33             ) or die IO::Socket::SSL->errstr;
34 18         10590 $socket->connect_SSL;
35 18 50 33     5688 if( $! != EAGAIN and $! != EWOULDBLOCK ) {
36 0         0 die IO::Socket::SSL::errstr();
37             }
38 18         153 my $self = bless {
39             socket => $socket,
40             started => 0,
41             fileno => $fileno,
42             method => 'connect_SSL',
43             on_connect => $connref,
44             }, $class;
45 18         225 return $self;
46             }
47              
48             qq[I TLSify!];
49              
50             __END__