Using Perl PayPal API on Debian wheezy

Created
Tue, 08/10/2013 - 06:00
Updated
Tue, 08/10/2013 - 06:00

I recently upgraded to Debian wheezy. On, Debian squeeze, I had no problem using the stock Perl module Business::PayPal::API to import PayPal transactions for Software Freedom Conservancy, via the Debian package libbusiness-paypal-api-perl.

After the wheezy upgrade, something goes wrong and it doesn't work. I reviewed some similar complaints, that seem to relate to this resolved bug, but that wasn't my problem, I don't think.

I ran strace to dig around and see what was going on. The working squeeeze install did this:

        select(8, [3], [3], NULL, {0, 0})       = 1 (out [3], left {0, 0})
        write(3, "SOMEDATA"..., 1365) = 1365
        rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
        rt_sigaction(SIGALRM, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
        rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
        rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
        rt_sigaction(SIGALRM, {0xxxxxx, [], 0}, {SIG_DFL, [], 0}, 8) = 0
        rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
        alarm(60)                               = 0
        read(3, "SOMEDATA", 5)               = 5
        

But the same script on wheezy did this at the same point:

        select(8, [3], [3], NULL, {0, 0})       = 1 (out [3], left {0, 0})
        write(3, "SOMEDATA"..., 1373) = 1373
        read(3, 0xxxxxxxx, 5)                   = -1 EAGAIN (Resource temporarily unavailable)
        select(0, NULL, NULL, NULL, {0, 100000}) = 0 (Timeout)
        read(3, 0xxxxxxxx, 5)                   = -1 EAGAIN (Resource temporarily unavailable)
        select(0, NULL, NULL, NULL, {0, 100000}) = 0 (Timeout)
        read(3, 0xxxxxxxx, 5)                   = -1 EAGAIN (Resource temporarily unavailable)
        select(0, NULL, NULL, NULL, {0, 100000}) = 0 (Timeout)
        read(3, 0xxxxxxxx, 5)                   = -1 EAGAIN (Resource temporarily unavailable)
        

I was pretty confused, and basically I still am, but then I noticed this in the documentation for Business::PayPal::API, regarding SOAP::Lite:

if you have already loaded Net::SSLeay (or IO::Socket::SSL), then Net::HTTPS will prefer to use IO::Socket::SSL. I don't know how to get SOAP::Lite to work with IO::Socket::SSL (e.g., Crypt::SSLeay uses HTTPS_* environment variables), so until then, you can use this hack: local $IO::Socket::SSL::VERSION = undef;

That hack didn't work, but I did confirm via strace that on wheezy, IO::Socket::SSL was getting loaded instead of Net::SSL. So, I did this, which was a complete and much worse hack:

        use Net::SSL;
        use Net::SSLeay;
        $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0;
        # Then:
        use Business::PayPal::API qw(GetTransactionDetails TransactionSearch);
        

… And this incantation worked. This isn't the right fix, but I figured I should publish this, as this ate up three hours, and it's worth the 15 minutes to write this post, just in case someone else tries to use Business::PayPal::API on wheezy.

I used to be a Perl expert once upon a time. This situation convinced me that I'm not. In the old days, I would've actually figured out what was wrong.