File Coverage

lib/Rex/Interface/Connection/HTTPS.pm
Criterion Covered Total %
statement 14 37 37.8
branch 0 8 0.0
condition 0 5 0.0
subroutine 5 10 50.0
pod 0 3 0.0
total 19 63 30.1


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Interface::Connection::HTTPS;
6              
7 1     1   15 use v5.12.5;
  1         4  
8 1     1   5 use warnings;
  1         3  
  1         25  
9 1     1   5 use Rex::Interface::Connection::HTTP;
  1         2  
  1         7  
10 1     1   24 use base qw(Rex::Interface::Connection::HTTP);
  1         4  
  1         91  
11              
12             our $VERSION = '1.14.2.2'; # TRIAL VERSION
13              
14 1     1   8 use Rex::Logger;
  1         1  
  1         7  
15              
16             sub new {
17 0     0 0   my $that = shift;
18 0   0       my $proto = ref($that) || $that;
19 0           my $self = $that->SUPER::new(@_);
20              
21 0           bless( $self, $proto );
22              
23 0           return $self;
24             }
25              
26 0     0 0   sub get_connection_type { return "HTTP"; }
27              
28             sub _get_proto {
29 0     0     return "https";
30             }
31              
32             sub _get_port {
33 0     0     my ( $self, $port ) = @_;
34 0   0       return $port || 8443;
35             }
36              
37             sub ua {
38 0     0 0   my ($self) = @_;
39 0 0         return $self->{ua} if $self->{ua};
40              
41 0           my $ssl_opts = {};
42              
43 0 0         if ( Rex::Config->get_ca ) {
44 0           Rex::Logger::debug("SSL: Verifying Hostname");
45 0           $ssl_opts->{verify_hostname} = 1;
46 0           $ssl_opts->{SSL_ca_file} = Rex::Config->get_ca;
47             }
48             else {
49 0           Rex::Logger::debug("SSL: NOT Verifying Hostname");
50 0           $ssl_opts->{verify_hostname} = 0;
51             }
52              
53 0 0         if ( Rex::Config->get_ca_cert ) {
54 0           $ssl_opts->{SSL_cert_file} = Rex::Config->get_ca_cert;
55             }
56              
57 0 0         if ( Rex::Config->get_ca_key ) {
58 0           $ssl_opts->{SSL_key_file} = Rex::Config->get_ca_key;
59             }
60              
61 0           $self->{ua} = LWP::UserAgent->new( ssl_opts => $ssl_opts, );
62             }
63              
64             1;