File Coverage

blib/lib/Cassandra/Client/TLSHandling.pm
Criterion Covered Total %
statement 28 45 62.2
branch 0 8 0.0
condition n/a
subroutine 10 14 71.4
pod 0 2 0.0
total 38 69 55.0


line stmt bran cond sub pod time code
1             package Cassandra::Client::TLSHandling;
2             our $AUTHORITY = 'cpan:TVDW';
3             $Cassandra::Client::TLSHandling::VERSION = '0.21';
4 13     13   219 use 5.010;
  13         48  
5 13     13   109 use strict;
  13         25  
  13         399  
6 13     13   62 use warnings;
  13         49  
  13         918  
7              
8             # SSLeay needs initialization
9 13     13   82 use Net::SSLeay 1.63 qw/die_now MODE_ENABLE_PARTIAL_WRITE MODE_ACCEPT_MOVING_WRITE_BUFFER/;
  13         330  
  13         1484  
10             BEGIN {
11 13     13   25001 Net::SSLeay::load_error_strings();
12 13         118 Net::SSLeay::SSLeay_add_ssl_algorithms();
13 13         138 Net::SSLeay::randomize();
14             }
15              
16 13     13   57934 use Devel::GlobalDestruction;
  13         35384  
  13         91  
17              
18             sub new {
19 0     0 0   my ($class)= @_;
20              
21 0 0         my $ctx= Net::SSLeay::CTX_new() or die_now("Unable to create OpenSSL context");
22 0           my $self= bless \$ctx, $class;
23              
24 0           Net::SSLeay::CTX_set_options($$self, Net::SSLeay::OP_ALL() | Net::SSLeay::OP_NO_SSLv2() | Net::SSLeay::OP_NO_SSLv3());
25 0           Net::SSLeay::CTX_set_mode($$self, MODE_ENABLE_PARTIAL_WRITE | MODE_ACCEPT_MOVING_WRITE_BUFFER);
26 0           return $self;
27             }
28              
29             sub new_conn {
30 0     0 0   my ($self)= @_;
31 0 0         my $tls= Net::SSLeay::new($$self) or die_now("Unable to create OpenSSL SSL object");
32 0           return bless \$tls, "Cassandra::Client::TLSHandling::conn";
33             }
34              
35             sub DESTROY {
36 0     0     local $@;
37 0 0         return if in_global_destruction;
38              
39 0           my $self= shift;
40              
41 0           Net::SSLeay::CTX_free($$self);
42             }
43              
44             1;
45              
46             package Cassandra::Client::TLSHandling::conn;
47             our $AUTHORITY = 'cpan:TVDW';
48             $Cassandra::Client::TLSHandling::conn::VERSION = '0.21';
49 13     13   6007 use 5.010;
  13         60  
50 13     13   96 use strict;
  13         29  
  13         316  
51 13     13   65 use warnings;
  13         26  
  13         596  
52              
53 13     13   68 use Devel::GlobalDestruction;
  13         47  
  13         56  
54              
55             sub DESTROY {
56 0     0     local $@;
57 0 0         return if in_global_destruction;
58              
59 0           my $self= shift;
60 0           Net::SSLeay::free($$self);
61             }
62              
63             1;
64              
65             __END__