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?


In reply to POSTing to an SNI enabled server. by enemyofthestate

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.