Subject: | start_SSL loses fileno after bless. |
While trying to convert an open accepted socket from IO::Socket::INET to IO::Socket:SSL, the fileno is somehow lost immediately after the bless.
Consider the following source from SSL.pm, I added 2 lines for debugging:
sub start_SSL {
my ($class,$socket) = (shift,shift);
return $class->error("Not a socket") unless(ref($socket));
my $arg_hash = (ref($_[0]) eq 'HASH') ? $_[0] : {@_};
my $original_class = ref($socket);
print "Before bless, fileno = " . fileno($socket) . "\n";
bless $socket, $class;
print "After bless, fileno = " . fileno($socket) . "\n";
$socket->configure_SSL($arg_hash) or bless($socket, $original_class) && return;
$arg_hash = ${*$socket}{'_SSL_arguments'};
print "Made it here.\n";
my $result = ($arg_hash->{'SSL_server'} ?
$socket->accept_SSL (${*$socket}{'_SSL_ctx'}, $arg_hash)
: $socket->connect_SSL($socket));
return $result ? $socket : bless($socket, $original_class) && ();
}
When run this (where $fh is an instance of IO::Socket::INET):
IO::Socket::SSL->start_SSL(
$fh,
SSL_server => 1,
SSL_key_file => 'server_key.pem',
SSL_cert_file => 'server_crt.pem',
);
I see the following output:
Before bless, fileno = 6
After bless, fileno =
Of course then shortly after that (With debug4 set):
Socket has no fileno
Which is generated from accept_SSL, and of course fails.