1Net::SSLeay::Handle(3)User Contributed Perl DocumentationNet::SSLeay::Handle(3)
2
3
4
6 Net::SSLeay::Handle - Perl module that lets SSL (HTTPS) sockets be
7 handled as standard file handles.
8
10 use Net::SSLeay::Handle qw/shutdown/;
11 my ($host, $port) = ("localhost", 443);
12
13 tie(*SSL, "Net::SSLeay::Handle", $host, $port);
14
15 print SSL "GET / HTTP/1.0\r\n";
16 shutdown(\*SSL, 1);
17 print while (<SSL>);
18 close SSL;
19
21 Net::SSLeay::Handle allows you to request and receive HTTPS web pages
22 using "old-fashion" file handles as in:
23
24 print SSL "GET / HTTP/1.0\r\n";
25
26 and
27
28 print while (<SSL>);
29
30 If you export the shutdown routine, then the only extra code that you
31 need to add to your program is the tie function as in:
32
33 my $socket;
34 if ($scheme eq "https") {
35 tie(*S2, "Net::SSLeay::Handle", $host, $port);
36 $socket = \*S2;
37 else {
38 $socket = Net::SSLeay::Handle->make_socket($host, $port);
39 }
40 print $socket $request_headers;
41 ...
42
44 shutdown
45 shutdown(\*SOCKET, $mode)
46
47 Calls to the main shutdown() don't work with tied sockets created
48 with this module. This shutdown should be able to distinquish
49 between tied and untied sockets and do the right thing.
50
51 debug
52 my $debug = Net::SSLeay::Handle->debug()
53 Net::SSLeay::Handle->debug(1)
54
55 Get/set debugging mode. Always returns the debug value before the
56 function call. if an additional argument is given the debug option
57 will be set to this value.
58
59 make_socket
60 my $sock = Net::SSLeay::Handle->make_socket($host, $port);
61
62 Creates a socket that is connected to $post using $port. It uses
63 $Net::SSLeay::proxyhost and proxyport if set and authentificates
64 itself against this proxy depending on $Net::SSLeay::proxyauth. It
65 also turns autoflush on for the created socket.
66
67 USING EXISTING SOCKETS
68 One of the motivations for writing this module was to avoid duplicating
69 socket creation code (which is mostly error handling). The calls to
70 tie() above where it is passed a $host and $port is provided for
71 convenience testing. If you already have a socket connected to the
72 right host and port, S1, then you can do something like:
73
74 my $socket \*S1;
75 if ($scheme eq "https") {
76 tie(*S2, "Net::SSLeay::Handle", $socket);
77 $socket = \*S2;
78 }
79 my $last_sel = select($socket); $| = 1; select($last_sel);
80 print $socket $request_headers;
81 ...
82
83 Note: As far as I know you must be careful with the globs in the tie()
84 function. The first parameter must be a glob (*SOMETHING) and the last
85 parameter must be a reference to a glob (\*SOMETHING_ELSE) or a scaler
86 that was assigned to a reference to a glob (as in the example above)
87
88 Also, the two globs must be different. When I tried to use the same
89 glob, I got a core dump.
90
91 EXPORT
92 None by default.
93
94 You can export the shutdown() function.
95
96 It is suggested that you do export shutdown() or use the fully
97 qualified Net::SSLeay::Handle::shutdown() function to shutdown SSL
98 sockets. It should be smart enough to distinguish between SSL and non-
99 SSL sockets and do the right thing.
100
102 use Net::SSLeay::Handle qw/shutdown/;
103 my ($host, $port) = ("localhost", 443);
104
105 tie(*SSL, "Net::SSLeay::Handle", $host, $port);
106
107 print SSL "GET / HTTP/1.0\r\n";
108 shutdown(\*SSL, 1);
109 print while (<SSL>);
110 close SSL;
111
113 Better error handling. Callback routine?
114
116 Tying to a file handle is a little tricky (for me at least).
117
118 The first parameter to tie() must be a glob (*SOMETHING) and the last
119 parameter must be a reference to a glob (\*SOMETHING_ELSE) or a scaler
120 that was assigned to a reference to a glob ($s = \*SOMETHING_ELSE).
121 Also, the two globs must be different. When I tried to use the same
122 glob, I got a core dump.
123
124 I was able to associate attributes to globs created by this module
125 (like *SSL above) by making a hash of hashes keyed by the file head1.
126
128 Please see Net-SSLeay-Handle-0.50/Changes file.
129
131 If you encounter a problem with this module that you believe is a bug,
132 please report it in one of the following ways:
133
134 · create a new issue <https://github.com/radiator-software/p5-net-
135 ssleay/issues/new> under the Net-SSLeay GitHub project at
136 <https://github.com/radiator-software/p5-net-ssleay>;
137
138 · open a ticket <https://rt.cpan.org/Ticket/Create.html?Queue=Net-
139 SSLeay> using the CPAN RT bug tracker's web interface at
140 <https://rt.cpan.org/Dist/Display.html?Queue=Net-SSLeay>;
141
142 · send an email to the CPAN RT bug tracker at
143 bug-Net-SSLeay@rt.cpan.org <mailto:bug-Net-SSLeay@rt.cpan.org>.
144
145 Please make sure your bug report includes the following information:
146
147 · the code you are trying to run;
148
149 · your operating system name and version;
150
151 · the output of "perl -V";
152
153 · the version of OpenSSL or LibreSSL you are using.
154
156 Originally written by Jim Bowlin.
157
158 Maintained by Sampo Kellomäki between July 2001 and August 2003.
159
160 Maintained by Florian Ragwitz between November 2005 and January 2010.
161
162 Maintained by Mike McCauley between November 2005 and June 2018.
163
164 Maintained by Chris Novakovic, Tuure Vartiainen and Heikki Vatiainen
165 since June 2018.
166
168 Copyright (c) 2001 Jim Bowlin <jbowlin@linklint.org>
169
170 Copyright (c) 2001-2003 Sampo Kellomäki <sampo@iki.fi>
171
172 Copyright (c) 2005-2010 Florian Ragwitz <rafl@debian.org>
173
174 Copyright (c) 2005-2018 Mike McCauley <mikem@airspayce.com>
175
176 Copyright (c) 2018- Chris Novakovic <chris@chrisn.me.uk>
177
178 Copyright (c) 2018- Tuure Vartiainen <vartiait@radiatorsoftware.com>
179
180 Copyright (c) 2018- Heikki Vatiainen <hvn@radiatorsoftware.com>
181
182 All rights reserved.
183
185 This module is released under the terms of the Artistic License 2.0.
186 For details, see the "LICENSE" file distributed with Net-SSLeay's
187 source code.
188
190 Net::SSLeay, perl(1), http://openssl.org/
191
192
193
194perl v5.32.0 2020-07-28 Net::SSLeay::Handle(3)