LightTCP-SSLclient

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

         }
      },
      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0"
         }
      },
      "runtime" : {
         "requires" : {
            "IO::Socket::INET" : "0",
            "IO::Socket::SSL" : "1.00",
            "MIME::Base64" : "0",
            "URI" : "0"
         }
      }
   },
   "release_status" : "stable",
   "resources" : {
      "bugtracker" : {
         "web" : "https://github.com/HansH111/LightTCP-SSLclient.pm/issues"
      },

META.yml  view on Meta::CPAN

meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: LightTCP-SSLclient
no_index:
  directory:
    - t
    - inc
requires:
  IO::Socket::INET: '0'
  IO::Socket::SSL: '1.00'
  MIME::Base64: '0'
  URI: '0'
resources:
  bugtracker: https://github.com/HansH111/LightTCP-SSLclient.pm/issues
  repository: https://github.com/HansH111/LightTCP-SSLclient.pm
version: '1.06'
x_serialization_backend: 'CPAN::Meta::YAML version 0.020'

Makefile.PL  view on Meta::CPAN

    PL_FILES          => {},
    EXE_FILES         => [
        'examples/ssltest.pl',
        'examples/simple_get.pl',
        'examples/simple_post.pl',
        'examples/simple_redirect.pl',
        'examples/simple_verbose.pl',
        'examples/simple_keepalive.pl',
    ],
    PREREQ_PM         => {
        'IO::Socket::SSL' => '1.00',
        'IO::Socket::INET'=> '0',
        'MIME::Base64'    => '0',
        'URI'             => '0',
    },
    BUILD_REQUIRES    => {
        'Test::More' => '0',
    },
    META_MERGE        => {
        resources => {
            repository => 'https://github.com/HansH111/LightTCP-SSLclient.pm',

README.md  view on Meta::CPAN

# Run with verbose output
prove -v t/01_constructor.t

# Run without building first
perl -I lib t/00_load.t
```

## Requirements

- Perl 5.8.1+
- `IO::Socket::SSL`
- `IO::Socket::INET`
- `MIME::Base64`
- `URI`

## License

This module is free software and may be modified and distributed under the same terms as Perl itself.

lib/LightTCP/SSLclient.pm  view on Meta::CPAN

package LightTCP::SSLclient;

use strict;
use warnings;
use IO::Socket::SSL;
use IO::Socket::INET;
use MIME::Base64 qw(encode_base64);
use URI;

our $VERSION = '1.06';

use base 'Exporter';

our @EXPORT_OK = qw(
    ECONNECT

lib/LightTCP/SSLclient.pm  view on Meta::CPAN

    my %ssl_opts = (
        SSL_verifycn_scheme => 'http',
        SSL_verifycn_name   => $target_host,
        SSL_hostname        => $target_host,
        Timeout             => $timeout,
        SSL_protocols       => $self->{ssl_protocols},
        SSL_cipher_list     => $self->{ssl_ciphers},
    );

    if ($self->{insecure}) {
        $ssl_opts{SSL_verify_mode} = IO::Socket::SSL::SSL_VERIFY_NONE;
    } else {
        $ssl_opts{SSL_verify_mode} = IO::Socket::SSL::SSL_VERIFY_PEER;
    }

    if ($self->{cert} && -f $self->{cert}.'.key' && -f $self->{cert}.'.crt') {
        $ssl_opts{SSL_key_file}  = $self->{cert}.'.key';
        $ssl_opts{SSL_cert_file} = $self->{cert}.'.crt';
    }

    if ($self->{verbose}) {
        push(@debug, "# === ssl_opts ===\n");
        foreach my $k (sort keys %ssl_opts) {

lib/LightTCP/SSLclient.pm  view on Meta::CPAN

            return (0, \@errors, \@debug, ECONNECT);
        }

        unless ($proxy_resp =~ /^HTTP\/1\.[01]\s+200\b/i) {
            $socket->close() if $socket;
            push(@errors, "- ERROR: Proxy CONNECT failed:\n$proxy_resp");
            return (0, \@errors, \@debug, ECONNECT);
        }
        push(@debug, "- Proxy tunnel established.\n") if $self->{verbose};

        if (IO::Socket::SSL->start_SSL($socket, %ssl_opts)) {
            $socket->timeout($timeout);
            push(@debug, "- SSL connect established.\n") if $self->{verbose};
            $self->{_socket}    = $socket;
            $self->{_connected} = 1;
            return (1, \@errors, \@debug, 0);
        } else {
            push(@errors, "- ERROR: SSL connect failed: $SSL_ERROR\n");
            return (0, \@errors, \@debug, ESSL);
        }
    } else {
        push(@debug, "# Connecting to $target_host:$target_port...\n") if $self->{verbose};
        $socket = IO::Socket::SSL->new(
            PeerHost => $target_host,
            PeerPort => $target_port,
            %ssl_opts,
        );
        if ($socket) {
            $socket->timeout($timeout);
            push(@debug, "- Direct SSL connect established.\n") if $self->{verbose};
            $self->{_socket}    = $socket;
            $self->{_connected} = 1;
            return (1, \@errors, \@debug, 0);



( run in 1.005 second using v1.01-cache-2.11-cpan-39bf76dae61 )