line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of POE-Component-SSLify |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is copyright (c) 2014 by Apocalypse. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
8
|
|
|
|
|
|
|
# |
9
|
13
|
|
|
13
|
|
312
|
use strict; use warnings; |
|
13
|
|
|
13
|
|
21
|
|
|
13
|
|
|
|
|
613
|
|
|
13
|
|
|
|
|
74
|
|
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
1030
|
|
10
|
|
|
|
|
|
|
package POE::Component::SSLify::ClientHandle; |
11
|
|
|
|
|
|
|
$POE::Component::SSLify::ClientHandle::VERSION = '1.010'; |
12
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:APOCAL'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: Client-side handle for SSLify |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Import the SSL death routines |
17
|
13
|
|
|
13
|
|
80
|
use Net::SSLeay 1.36 qw( die_now die_if_ssl_error ); |
|
13
|
|
|
|
|
258
|
|
|
13
|
|
|
|
|
755
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# We inherit from ServerHandle |
20
|
13
|
|
|
13
|
|
7438
|
use parent 'POE::Component::SSLify::ServerHandle'; |
|
13
|
|
|
|
|
3898
|
|
|
13
|
|
|
|
|
67
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Override TIEHANDLE because we create a CTX |
23
|
|
|
|
|
|
|
sub TIEHANDLE { |
24
|
29
|
|
|
29
|
|
61
|
my ( $class, $socket, $version, $options, $ctx, $connref ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# create a context, if necessary |
27
|
29
|
100
|
|
|
|
85
|
if ( ! defined $ctx ) { |
28
|
3
|
|
|
|
|
15
|
$ctx = POE::Component::SSLify::_createSSLcontext( undef, undef, $version, $options ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
29
|
50
|
|
|
|
347
|
my $ssl = Net::SSLeay::new( $ctx ) or die_now( "Failed to create SSL $!" ); |
32
|
|
|
|
|
|
|
|
33
|
29
|
|
|
|
|
55
|
my $fileno = fileno( $socket ); |
34
|
|
|
|
|
|
|
|
35
|
29
|
|
|
|
|
166
|
Net::SSLeay::set_fd( $ssl, $fileno ); # Must use fileno |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Socket is in non-blocking mode, so connect() will return immediately. |
38
|
|
|
|
|
|
|
# die_if_ssl_error won't die on non-blocking errors. We don't need to call connect() |
39
|
|
|
|
|
|
|
# again, because OpenSSL I/O functions (read, write, ...) can handle that entirely |
40
|
|
|
|
|
|
|
# by self (it's needed to connect() once to determine connection type). |
41
|
29
|
50
|
|
|
|
3581
|
my $res = Net::SSLeay::connect( $ssl ) or die_if_ssl_error( 'ssl connect' ); |
42
|
|
|
|
|
|
|
|
43
|
29
|
|
|
|
|
311
|
my $self = bless { |
44
|
|
|
|
|
|
|
'ssl' => $ssl, |
45
|
|
|
|
|
|
|
'ctx' => $ctx, |
46
|
|
|
|
|
|
|
'socket' => $socket, |
47
|
|
|
|
|
|
|
'fileno' => $fileno, |
48
|
|
|
|
|
|
|
'client' => 1, |
49
|
|
|
|
|
|
|
'status' => $res, |
50
|
|
|
|
|
|
|
'on_connect' => $connref, |
51
|
|
|
|
|
|
|
}, $class; |
52
|
|
|
|
|
|
|
|
53
|
29
|
|
|
|
|
278
|
return $self; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |