| 1 | package Net::HTTPS; | ||||||||||||||||||||||
| 2 | 2 | our $VERSION = '6.22'; | |||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 5 | |||||||||||||||||||||||
| 6 | # Figure out which SSL implementation to use | ||||||||||||||||||||||
| 7 | 2 | our $SSL_SOCKET_CLASS; | |||||||||||||||||||||
| 8 | 2 | ▶ | if ($SSL_SOCKET_CLASS) { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 9 | # somebody already set it | ||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||
| 11 | elsif ($SSL_SOCKET_CLASS = $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS}) { | ||||||||||||||||||||||
| 12 | 0 | ▶ | unless ($SSL_SOCKET_CLASS =~ /^(IO::Socket::SSL|Net::SSL)\z/) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 13 | 0 | die "Bad socket class [$SSL_SOCKET_CLASS]"; | |||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||
| 15 | 0 | eval "require $SSL_SOCKET_CLASS"; | |||||||||||||||||||||
| 16 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||
| 18 | elsif ($IO::Socket::SSL::VERSION) { | ||||||||||||||||||||||
| 19 | 1 | $SSL_SOCKET_CLASS = "IO::Socket::SSL"; # it was already loaded | |||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||
| 21 | elsif ($Net::SSL::VERSION) { | ||||||||||||||||||||||
| 22 | 0 | $SSL_SOCKET_CLASS = "Net::SSL"; | |||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||
| 24 | else { | ||||||||||||||||||||||
| 25 | 0 | eval { require IO::Socket::SSL; }; | |||||||||||||||||||||
| 26 | 0 | ▶ | if ($@) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 27 | 0 | my $old_errsv = $@; | |||||||||||||||||||||
| 28 | 0 | eval { | |||||||||||||||||||||
| 29 | 0 | require Net::SSL; # from Crypt-SSLeay | |||||||||||||||||||||
| 30 | }; | ||||||||||||||||||||||
| 31 | 0 | ▶ | if ($@) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 32 | 0 | $old_errsv =~ s/\s\(\@INC contains:.*\)/)/g; | |||||||||||||||||||||
| 33 | 0 | die $old_errsv . $@; | |||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||
| 35 | 0 | $SSL_SOCKET_CLASS = "Net::SSL"; | |||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||
| 37 | else { | ||||||||||||||||||||||
| 38 | 0 | $SSL_SOCKET_CLASS = "IO::Socket::SSL"; | |||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||
| 41 | |||||||||||||||||||||||
| 42 | 2 | require Net::HTTP::Methods; | |||||||||||||||||||||
| 43 | |||||||||||||||||||||||
| 44 | 2 | our @ISA=($SSL_SOCKET_CLASS, 'Net::HTTP::Methods'); | |||||||||||||||||||||
| 45 | |||||||||||||||||||||||
| 46 | sub configure { | ||||||||||||||||||||||
| 47 | 1 | ▶ | my($self, $cnf) = @_; | ||||||||||||||||||||
|
Subroutine
configure: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||
| 48 | 1 | $self->http_configure($cnf); | |||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||
| 50 | |||||||||||||||||||||||
| 51 | sub http_connect { | ||||||||||||||||||||||
| 52 | 1 | ▶ | my($self, $cnf) = @_; | ||||||||||||||||||||
|
Subroutine
http_connect: called CC=6 SCAR=32.2
Pod
undocumented
| |||||||||||||||||||||||
| 53 | 1 | ▶ | if ($self->isa("Net::SSL")) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 54 | 0 | ▶ | if ($cnf->{SSL_verify_mode}) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 55 | 0 | ▶ | if (my $f = $cnf->{SSL_ca_file}) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 56 | 0 | $ENV{HTTPS_CA_FILE} = $f; | |||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||
| 58 | 0 | ▶ | if (my $f = $cnf->{SSL_ca_path}) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 59 | 0 | $ENV{HTTPS_CA_DIR} = $f; | |||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||
| 62 | 0 | ▶ | if ($cnf->{SSL_verifycn_scheme}) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 63 | 0 | $@ = "Net::SSL from Crypt-SSLeay can't verify hostnames; either install IO::Socket::SSL or turn off verification by setting the PERL_LWP_SSL_VERIFY_HOSTNAME environment variable to 0"; | |||||||||||||||||||||
| 64 | 0 | return undef; | |||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||
| 67 | 1 | $self->SUPER::configure($cnf); | |||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||
| 69 | |||||||||||||||||||||||
| 70 | sub http_default_port { | ||||||||||||||||||||||
| 71 | 2 | ▶ | 443; | ||||||||||||||||||||
|
Subroutine
http_default_port: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||
| 73 | |||||||||||||||||||||||
| 74 | 2 | ▶ | if ($SSL_SOCKET_CLASS eq "Net::SSL") { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 75 | # The underlying SSLeay classes fails to work if the socket is | ||||||||||||||||||||||
| 76 | # placed in non-blocking mode. This override of the blocking | ||||||||||||||||||||||
| 77 | # method makes sure it stays the way it was created. | ||||||||||||||||||||||
| 78 | 0 | ▶ | *blocking = sub { }; | ||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||
| 80 | |||||||||||||||||||||||
| 81 | 2 | 1; | |||||||||||||||||||||
| 82 | |||||||||||||||||||||||
| 83 | =pod | ||||||||||||||||||||||
| 84 | |||||||||||||||||||||||
| 85 | =encoding UTF-8 | ||||||||||||||||||||||
| 86 | |||||||||||||||||||||||
| 87 | =head1 NAME | ||||||||||||||||||||||
| 88 | |||||||||||||||||||||||
| 89 | Net::HTTPS - Low-level HTTP over SSL/TLS connection (client) | ||||||||||||||||||||||
| 90 | |||||||||||||||||||||||
| 91 | =head1 VERSION | ||||||||||||||||||||||
| 92 | |||||||||||||||||||||||
| 93 | version 6.22 | ||||||||||||||||||||||
| 94 | |||||||||||||||||||||||
| 95 | =head1 DESCRIPTION | ||||||||||||||||||||||
| 96 | |||||||||||||||||||||||
| 97 | The C<Net::HTTPS> is a low-level HTTP over SSL/TLS client. The interface is the same | ||||||||||||||||||||||
| 98 | as the interface for C<Net::HTTP>, but the constructor takes additional parameters | ||||||||||||||||||||||
| 99 | as accepted by L<IO::Socket::SSL>. The C<Net::HTTPS> object is an C<IO::Socket::SSL> | ||||||||||||||||||||||
| 100 | too, which makes it inherit additional methods from that base class. | ||||||||||||||||||||||
| 101 | |||||||||||||||||||||||
| 102 | For historical reasons this module also supports using C<Net::SSL> (from the | ||||||||||||||||||||||
| 103 | Crypt-SSLeay distribution) as its SSL driver and base class. This base is | ||||||||||||||||||||||
| 104 | automatically selected if available and C<IO::Socket::SSL> isn't. You might | ||||||||||||||||||||||
| 105 | also force which implementation to use by setting $Net::HTTPS::SSL_SOCKET_CLASS | ||||||||||||||||||||||
| 106 | before loading this module. If not set this variable is initialized from the | ||||||||||||||||||||||
| 107 | C<PERL_NET_HTTPS_SSL_SOCKET_CLASS> environment variable. | ||||||||||||||||||||||
| 108 | |||||||||||||||||||||||
| 109 | =head1 ENVIRONMENT | ||||||||||||||||||||||
| 110 | |||||||||||||||||||||||
| 111 | You might set the C<PERL_NET_HTTPS_SSL_SOCKET_CLASS> environment variable to the name | ||||||||||||||||||||||
| 112 | of the base SSL implementation (and Net::HTTPS base class) to use. The default | ||||||||||||||||||||||
| 113 | is C<IO::Socket::SSL>. Currently the only other supported value is C<Net::SSL>. | ||||||||||||||||||||||
| 114 | |||||||||||||||||||||||
| 115 | =head1 SEE ALSO | ||||||||||||||||||||||
| 116 | |||||||||||||||||||||||
| 117 | L<Net::HTTP>, L<IO::Socket::SSL> | ||||||||||||||||||||||
| 118 | |||||||||||||||||||||||
| 119 | =head1 AUTHOR | ||||||||||||||||||||||
| 120 | |||||||||||||||||||||||
| 121 | Gisle Aas <gisle@activestate.com> | ||||||||||||||||||||||
| 122 | |||||||||||||||||||||||
| 123 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||
| 124 | |||||||||||||||||||||||
| 125 | This software is copyright (c) 2001 by Gisle Aas. | ||||||||||||||||||||||
| 126 | |||||||||||||||||||||||
| 127 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||
| 128 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||
| 129 | |||||||||||||||||||||||
| 130 | =cut | ||||||||||||||||||||||
| 131 | |||||||||||||||||||||||
| 132 | __END__ | ||||||||||||||||||||||