Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can_read issue with Net::SSL [rt.cpan.org #98898] #61

Open
oalders opened this issue May 16, 2019 · 0 comments
Open

can_read issue with Net::SSL [rt.cpan.org #98898] #61

oalders opened this issue May 16, 2019 · 0 comments

Comments

@oalders
Copy link
Member

oalders commented May 16, 2019

Migrated from rt.cpan.org#98898 (status was 'open')

Requestors:

From hv@crypt.org on 2014-09-15 13:09:32
:

My $work app has encountered a problem that I believe is identical to
rt#81237, but with Net::SSL rather than IO::Socket::SSL as the underlying
socket library.

Our current plan to address this is to upgrade to latest Crypt::SSLeay
(which exposed the 'pending' method in a recent change) and then apply
the following local patch (against Net-HTTP-6.06, but should apply over
6.07 as well):

--- lib/perl5/Net/HTTP/Methods.pm.old   2013-03-10 22:35:43.000000000 +0000
+++ lib/perl5/Net/HTTP/Methods.pm   2014-09-15 14:05:38.000000000 +0100
@@ -284,6 +284,7 @@
     my $self = shift;
     return 1 unless defined(fileno($self));
     return 1 if $self->isa('IO::Socket::SSL') && $self->pending;
+    return 1 if $self->isa('Net::SSL') && $self->pending;

     # With no timeout, wait forever.  An explict timeout of 0 can be
     # used to just check if the socket is readable without waiting.

It looks like the support for pending() came in between 0.65_02 and 0.65_04
of Crypt::SSLeay, so it isn't obvious how Net::HTTP should incorporate
a similar fix - if you're using an older Crypt::SSLeay you'll get something
like:
  Can't locate object method "pending" via package "LWP::Protocol::https::Socket" at lib/perl5/Net/HTTP/Methods.pm line 287.

Hugo


From http://xlogon.net/amock on 2014-10-15 12:48:54
:

Hi all,

I'm pretty sure that I was just hit by this bug too. 
I'm using LWP to make HTTP POST requests to a site. 

The following combination works fast as expected:

Net::HTTP 6.01
Crypt::SSLeay 0.57
IO::Socket::INET 1.31

The follwoing combination does return after a long period (timeout):
Net::HTTP 6.06 also 6.07
Crypt::SSLeay 0.57
IO::Socket::INET 1.31

I found the same portion of code with profiling the weired test run with Devel::NYTProf showing that the call to can_read spent most of the time.

Following the proposed patch I installed newest Crypt::SSLeay and Net::HTTP, added the line and the measured runtime is as expected.

I'm writing this because I'm pretty sure that this bug happens in the wild and is a kind of backward compatibility regression of Net::HTTP.
Important is that the method 'pending' of 'Net::SSL' is introduced in one of the younger versions. The right dependencies must be set.

Regards
McA


From http://xlogon.net/amock on 2014-10-15 14:34:21
:

As an addendum:
I did some research on that to find a solution to my problem. It seems that the usage of Net::SSL as part of Crypt::SSLeay to make SSL connections is deprecated (version 0.72). As soon as you install that version the module LWP::Protocol::https is pulled from CPAN if it's not installed before. With that installation IO::Socket::SSL should be pulled from CPAN to do the whole SSL stuff in favour of Net::SSL.

So, as soon as you hit the bug you should check why you're using Net::SSL and not IO::Socket::SSL. In my case is seems to be a strange history of dependency resolution.

Regards
McA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant