ikegami / perl-LWP-Protocol-AnyEvent-http

Event loop friendly HTTP and HTTPS backend for Perl's LWP
http://search.cpan.org/dist/LWP-Protocol-AnyEvent-http/
Creative Commons Zero v1.0 Universal
9 stars 6 forks source link

Utilize the LWP ssl_opts to configure ssl peer verification #6

Closed frett closed 11 years ago

ikegami commented 11 years ago

Hello,

The license I use is less restrictive than LWP-Protocol-https's so I can't just take code from it. Most of the code you posted is yours or required to use the relevant APIs, but I'll have to ask before I can copy that error message.

ikegami commented 11 years ago

Merged and uploaded to CPAN in 1.0.7. Thanks for your contribution.

ghost commented 11 years ago

I found a case where it's not working correctly. The following script works fine, where $rpc is a subclass of LWP::UserAgent:

#!/usr/bin/env perl
use strict;
use warnings;
use Finance::Bitcoin::API;

my $rpc = Finance::Bitcoin::API->new(
    endpoint => "https://rpc.blockchain.info/"
);

my $ua = $rpc->jsonrpc->ua;
$ua->set_my_handler(
    response_done => sub { $_[0]->dump(maxlength => 0); return }
);

my $res = $rpc->call(getinfo => ());

It successfully handles the SSL handshake, though it does produce a higher-level error because the user credentials are missing.

But Using LWP::Protocol::AnyEvent::http results in an SSL handshake error:

#!/usr/bin/env perl
use strict;
use warnings;
use Finance::Bitcoin::API;
use Coro qw(async);
use LWP::Protocol::AnyEvent::http;

my $rpc = Finance::Bitcoin::API->new(
    endpoint => "https://rpc.blockchain.info/"
);

my $ua = $rpc->jsonrpc->ua;
$ua->set_my_handler(
    response_done => sub { $_[0]->dump(maxlength => 0); return }
);

async {
    my $res = $rpc->call(getinfo => ());
}->join;