enemyofthestate has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to modify some old code (from 2006) to POST to an SNI enabled server. It is not working as I expect. According to everything I been able find the relevant modules are up-to-date enough to do this:
LWP 6.33 HTTP::Request 6.14 IO::Socket::SSL 2.056 OpenSSL 1.0.1
I still get an error 403. I can POST the data using wget so I am guessing there is a problem in how I setting it up. This outlines the procedure I am using.
use LWP; use HTTP::Request; sub post_cert my ($url,$certificate,$encode,$certno) = @_; # create the user agent my $agent = new LWP::UserAgent or return (0,"Unable to create HTTP A +gent"); $agent->agent("Agent ID"); # create a request my $request = new HTTP::Request POST=>$url; my $post = "Buncha XML Certificate Data"; # set the host: header (for SNI) my ($host) = $url =~ m|https?://([^:/]+)|; $request->header("Host", $host); # ready -- load content $request->content($post); # fire $response = $agent->request($request); # aim if ($response->is_success) { undef $response; undef $request; undef $agent; $message = "$certno: send to $url successful"; return (1,$message); } $message = "$certno: send to $url failed\n"; $message .= "$certno: Remote said: " . $response->status_line . "\n" +; undef $agent; return (0,$message); }
Help?
|
|---|