line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::HTTPS; |
2
|
|
|
|
|
|
|
our $VERSION = '6.21'; |
3
|
2
|
|
|
2
|
|
196966
|
use strict; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
82
|
|
4
|
2
|
|
|
2
|
|
17
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1113
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Figure out which SSL implementation to use |
7
|
|
|
|
|
|
|
our $SSL_SOCKET_CLASS; |
8
|
|
|
|
|
|
|
if ($SSL_SOCKET_CLASS) { |
9
|
|
|
|
|
|
|
# somebody already set it |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
elsif ($SSL_SOCKET_CLASS = $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS}) { |
12
|
|
|
|
|
|
|
unless ($SSL_SOCKET_CLASS =~ /^(IO::Socket::SSL|Net::SSL)\z/) { |
13
|
|
|
|
|
|
|
die "Bad socket class [$SSL_SOCKET_CLASS]"; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
eval "require $SSL_SOCKET_CLASS"; |
16
|
|
|
|
|
|
|
die $@ if $@; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
elsif ($IO::Socket::SSL::VERSION) { |
19
|
|
|
|
|
|
|
$SSL_SOCKET_CLASS = "IO::Socket::SSL"; # it was already loaded |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
elsif ($Net::SSL::VERSION) { |
22
|
|
|
|
|
|
|
$SSL_SOCKET_CLASS = "Net::SSL"; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
|
|
|
|
|
|
eval { require IO::Socket::SSL; }; |
26
|
|
|
|
|
|
|
if ($@) { |
27
|
|
|
|
|
|
|
my $old_errsv = $@; |
28
|
|
|
|
|
|
|
eval { |
29
|
|
|
|
|
|
|
require Net::SSL; # from Crypt-SSLeay |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
if ($@) { |
32
|
|
|
|
|
|
|
$old_errsv =~ s/\s\(\@INC contains:.*\)/)/g; |
33
|
|
|
|
|
|
|
die $old_errsv . $@; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
$SSL_SOCKET_CLASS = "Net::SSL"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
|
|
|
|
|
|
$SSL_SOCKET_CLASS = "IO::Socket::SSL"; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
require Net::HTTP::Methods; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
our @ISA=($SSL_SOCKET_CLASS, 'Net::HTTP::Methods'); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub configure { |
47
|
1
|
|
|
1
|
0
|
1068
|
my($self, $cnf) = @_; |
48
|
1
|
|
|
|
|
12
|
$self->http_configure($cnf); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub http_connect { |
52
|
1
|
|
|
1
|
0
|
3
|
my($self, $cnf) = @_; |
53
|
1
|
50
|
|
|
|
17
|
if ($self->isa("Net::SSL")) { |
54
|
0
|
0
|
|
|
|
0
|
if ($cnf->{SSL_verify_mode}) { |
55
|
0
|
0
|
|
|
|
0
|
if (my $f = $cnf->{SSL_ca_file}) { |
56
|
0
|
|
|
|
|
0
|
$ENV{HTTPS_CA_FILE} = $f; |
57
|
|
|
|
|
|
|
} |
58
|
0
|
0
|
|
|
|
0
|
if (my $f = $cnf->{SSL_ca_path}) { |
59
|
0
|
|
|
|
|
0
|
$ENV{HTTPS_CA_DIR} = $f; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
0
|
0
|
|
|
|
0
|
if ($cnf->{SSL_verifycn_scheme}) { |
63
|
0
|
|
|
|
|
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
|
|
|
|
|
0
|
return undef; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
1
|
|
|
|
|
8
|
$self->SUPER::configure($cnf); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub http_default_port { |
71
|
2
|
|
|
2
|
0
|
126
|
443; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
if ($SSL_SOCKET_CLASS eq "Net::SSL") { |
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
|
|
|
|
|
|
|
*blocking = sub { }; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
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.21 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 DESCRIPTION |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
The C is a low-level HTTP over SSL/TLS client. The interface is the same |
98
|
|
|
|
|
|
|
as the interface for C, but the constructor takes additional parameters |
99
|
|
|
|
|
|
|
as accepted by L. The C object is an C |
100
|
|
|
|
|
|
|
too, which makes it inherit additional methods from that base class. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
For historical reasons this module also supports using C (from the |
103
|
|
|
|
|
|
|
Crypt-SSLeay distribution) as its SSL driver and base class. This base is |
104
|
|
|
|
|
|
|
automatically selected if available and C 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 environment variable. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 ENVIRONMENT |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
You might set the C environment variable to the name |
112
|
|
|
|
|
|
|
of the base SSL implementation (and Net::HTTPS base class) to use. The default |
113
|
|
|
|
|
|
|
is C. Currently the only other supported value is C. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 SEE ALSO |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L, L |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 AUTHOR |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Gisle Aas |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This software is copyright (c) 2001-2017 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__ |