Search code examples
perlopensslperldoc

Net::SSLeay post_https compilation error: Too many arguments


I'm interfacing with a payment gateway and not having any luck with Net::SSLeay and its post_https subroutine. The payment gateway has issued me a client certificate that must be used for authentication. The Net::SSLeay perldoc has the following example:

($page, $response, %reply_headers)
         = post_https('www.bacus.pt', 443, '/foo.cgi',           # 3b
              make_headers('Authorization' =>
                           'Basic ' . MIME::Base64::encode("$user:$pass",'')),
              make_form(OK   => '1', name => 'Sampo'),
              $mime_type6, $path_to_crt7, $path_to_key8);

My own version is below and returns the error Too many arguments for Net::SSLeay::post_https:

#!/usr/bin/perl

use strict;
use warnings;
use Net::SSLeay qw(post_https);

my %post = (
    #snip
);

my ($page, $response, %reply_headers) = post_https(
    'www.example.com',
    443,
    '/submit',
    '',
    make_form(%post),
    'text/xml',
    '/path/to/cert',
    '/path/to/key',
);

Why is this error occurring?


Solution

  • New versions of Net::SSLeay don't have the prototype that old versions have. Reading the source of old and new version I'd say the prototype was a bug (the code it calls can handle more variables than advertised).

    The solution I recommend is upgrading to a newer version of Net::SSLeay. If that is not possible, calling it like &post_https can be a quick but ugly fix.