Net::SS...::Handle(3)
π Net::SS...::Handle(3) β the Perl module that lets SSL (HTTPS) sockets be handled as standard file handles π¦
okay bestie, you're reading the user-contributed Perl documentation for Net::SSLeay::Handle, and no cap, it's kind of a vibe. let me walk you through it π
β¨ NAME β¨
Net::SSLeay::Handle β Perl module that lets SSL (HTTPS) sockets be handled as standard file handles. literally that's the whole personality π
πΈ SYNOPSIS πΈ
use Net::SSLeay::Handle qw/shutdown/;
my ($host, $port) = ("localhost", 443);
tie(*SSL, "Net::SSLeay::Handle", $host, $port);
print SSL "GET / HTTP/1.0\r\n";
shutdown(\*SSL, 1);
print while (<SSL>);
close SSL;
like, that's it. that's the whole flex π€
π¦ DESCRIPTION π¦
Net::SSLeay::Handle lets you request and receive HTTPS web pages using "old-fashion" file handles, as in:
print SSL "GET / HTTP/1.0\r\n";
and
print while (<SSL>);
if you export the shutdown routine, then the only extra code you need to add to your program is the tie function, like this:
my $socket;
if ($scheme eq "https") {
tie(*S2, "Net::SSLeay::Handle", $host, $port);
$socket = \*S2;
else {
$socket = Net::SSLeay::Handle->make_socket($host, $port);
}
print $socket $request_headers;
...
(yeah, that else block in the original is missing its closing brace β not me, that's canon, iykyk π)
π₯ FUNCTIONS π₯
β shutdown
shutdown(\*SOCKET, $mode)
calls to the main shutdown() don't work with tied sockets created with this module. this shutdown should be able to distinquish between tied and untied sockets and do the right thing. bestie it knows things π
β debug
my $debug = Net::SSLeay::Handle->debug()
Net::SSLeay::Handle->debug(1)
get/set debugging mode. always returns the debug value before the function call. if an additional argument is given, the debug option will be set to this value. so you never lose track of where you were, periodt π
β make_socket
my $sock = Net::SSLeay::Handle->make_socket($host, $port);
creates a socket that is connected to $post using $port. it uses $Net::SSLeay::proxyhost and proxyport if set, and authentificates itself against this proxy depending on $Net::SSLeay::proxyauth. it also turns autoflush on for the created socket. (yes, the docs say $post β original flavor, we keep it π)
π§ USING EXISTING SOCKETS π§
one of the motivations for writing this module was to avoid duplicating socket creation code (which is mostly error handling). the calls to tie() above where it is passed a $host and $port are provided for convenience testing. if you already have a socket connected to the right host and port, S1, then you can do something like:
my $socket \*S1;
if ($scheme eq "https") {
tie(*S2, "Net::SSLeay::Handle", $socket);
$socket = \*S2;
}
my $last_sel = select($socket); $| = 1; select($last_sel);
print $socket $request_headers;
...
β οΈ Note: as far as I know you must be careful with the globs in thetie()function. the first parameter must be a glob (*SOMETHING) and the last parameter must be a reference to a glob (\*SOMETHING_ELSE) or a scaler that was assigned to a reference to a glob (as in the example above).
also, the two globs must be different. when I tried to use the same glob, I got a core dump. π like, actual core dump. do not do that. π
π«Ά EXPORT π«Ά
none by default.
you can export the shutdown() function.
it is suggested that you do export shutdown() or use the fully qualified Net::SSLeay::Handle::shutdown() function to shutdown SSL sockets. it should be smart enough to distinguish between SSL and non-SSL sockets and do the right thing. she's got range π
π EXAMPLES π
use Net::SSLeay::Handle qw/shutdown/;
my ($host, $port) = ("localhost", 443);
tie(*SSL, "Net::SSLeay::Handle", $host, $port);
print SSL "GET / HTTP/1.0\r\n";
shutdown(\*SSL, 1);
print while (<SSL>);
close SSL;
copy-paste-able, iconic, no notes π
π TODO π
better error handling. callback routine?
(we love an honest queen β¨)
π CAVEATS π
tying to a file handle is a little tricky (for me at least). π«
the first parameter to tie() must be a glob (*SOMETHING) and the last parameter must be a reference to a glob (\*SOMETHING_ELSE) or a scaler that was assigned to a reference to a glob ($s = \*SOMETHING_ELSE). also, the two globs must be different. when I tried to use the same glob, I got a core dump. ππ
I was able to associate attributes to globs created by this module (like *SSL above) by making a hash of hashes keyed by the file head1.
π¦ CHANGES π¦
please see Net-SSLeay-Handle-0.50/Changes file. β¨
π BUGS π
if you encounter a problem with this module that you believe is a bug, please create a new issue in the Net-SSLeay GitHub repository at https://github.com/radiator-software/p5-net-ssleay/issues/new. please make sure your bug report includes the following information:
- the code you are trying to run;
- your operating system name and version;
- the output of
perl -V; - the version of OpenSSL or LibreSSL you are using.
like pls include all of it, we can't debug vibes alone ππ«Ά
π AUTHOR π
originally written by Jim Bowlin.
maintained by Sampo KellomΓ€ki between July 2001 and August 2003.
maintained by Florian Ragwitz between November 2005 and January 2010.
maintained by Mike McCauley between November 2005 and June 2018.
maintained by Tuure Vartiainen between June 2018 and July 2018.
maintained by Chris Novakovic and Heikki Vatiainen since June 2018.
look at that handoff chain, it's giving relay race πββοΈβ¨
π COPYRIGHT π
copyright (c) 2001 Jim Bowlin <jbowlin@linklint.org>
copyright (c) 2001-2003 Sampo KellomΓ€ki <sampo@iki.fi>
copyright (c) 2005-2010 Florian Ragwitz <rafl@debian.org>
copyright (c) 2005-2018 Mike McCauley <mikem@airspayce.com>
copyright (c) 2018 Tuure Vartiainen <vartiait@radiatorsoftware.com>
copyright (c) 2018- Chris Novakovic <chris@chrisn.me.uk>
copyright (c) 2018- Heikki Vatiainen <hvn@radiatorsoftware.com>
all rights reserved. π
πΈ LICENSE πΈ
this module is released under the terms of the Artistic License 2.0. for details, see the LICENSE file distributed with Net-SSLeay's source code.
π§ SEE ALSO π§
Net::SSLeay, perl(1), http://openssl.org/
okay that's the whole page bestie, go forth and tie your globs (to different globs, please π). this was perl v5.42.0, dated 2025-04-09, from the Net::SS...::Handle(3) man page β mwah, love u, bye ππ¦β¨π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Net-SSLeay 1.940.0-160000.2.2 Β· Artistic-2.0
- opensuse-leap 16.0: perl-Net-SSLeay 1.940.0-160000.2.2 Β· Artistic-2.0
- opensuse-leap 16.0: perl-Net-SSLeay 1.940.0-160000.2.2 Β· Artistic-2.0
- opensuse-leap 16.0: perl-Net-SSLeay 1.940.0-160000.2.2 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms