logo       

Problem using HTML::Form with LWP & SSL: msg#00049

lang.perl.modules.lwp

Subject: Problem using HTML::Form with LWP & SSL

Greetings,

Having a problem parsing a returned form now that SSL has been enabled at
the target.

My application would connect to eBay specifying the page to "change an
auction item description".
I would then catch the returned login page, fill in the userid/password and
would then be directed
to the page to start change item description process (Enter Item Number
page form).

Since eBay has enabled SSL for signing in (couple days ago) my app breaks
when trying to parse for the
input area on the Add Description form using HTML::Form.

I changed the first form parse to specify an https url base and do receive
the login page fine and am able to parse/update/submit
the userid/password using HTML::Form. The Add Description page comes back
ok but the last HTML::Form parse below fails
when I issue that against the returned html. I dumped some headers on this
received page that indicate SSL is in effect but
if I save the page and bring it up in a browser the properties of the page
indicate it's straight http.

Not sure how to further debug the HTML::Form that's failing below.

Here's the SSL header info -

head1 - AES256-SHA
head2 - /C=US/ST=California/L=San Jose/O=eBay Inc./OU=Site
Operations/CN=signin.ebay.com
head3 - /C=US/O=RSA Data Security, Inc./OU=Secure Server Certification
Authority
status is 200 OK

I learned that I needed to have the correct Perl mods for LWP to handle SSL
installed on my server and made sure
they were there. Crypt::SSLeay and Net::SSLeay were already present and I
had IO::Socket::SSL
added. This is all running on RHEL 3.

Any assistance/guidance/pointers are most appreciated.

Thanks,
Steve

Snipit that talks to eBay for Add to Item Description -

#---------------------------------------------------------------------------
---------------------
# Try to "Add to Item Description" to get the login page (this will return
the Login page first)
#---------------------------------------------------------------------------
---------------------
my $ua = LWP::UserAgent->new;
$ua->cookie_jar(HTTP::Cookies->new(file => "$CustCookieFile", autosave =>
1));

$sign_in_page='http://cgi5.ebay.com/ws/eBayISAPI.dll?AddToItemDescription&fr
omryilanding=2';

my $r = $ua->request(HTTP::Request->new(GET => "$sign_in_page"));
$html = $r->content;

@forms = HTML::Form->parse($html,'https://signin.ebay.com');

$name= 'userid';
$form_password = 'pass';

#print "This should be the login page - <BR> $html <BR>";
#---------------------------------------------------------
# Fill in the Userid and Password fields on the login Page
#---------------------------------------------------------
$input_userid = $forms[1]->find_input($name);
$input_pass = $forms[1]->find_input($form_password);
$input_userid -> value($userid);
$input_pass -> value($ebaypassword);

#------------------------------------------------
# Click the login Submit button on the Login Page
#------------------------------------------------
for my $find_sub ($forms[1]->inputs) {
next unless $find_sub ->type eq 'submit';
$keep_find_sub = $find_sub;
}
my $req2 = $keep_find_sub->click($forms[1]);
my $uri2 = new $HTTP::URI_CLASS($req2->uri);
$req2->uri($uri2);
my $r2 = $ua->simple_request($req2);
while ($r2->is_redirect) {
my $u2 = $r2->header('location') or die "missing location: ",
$r2->as_string;
# print "redirecting to $u2\n";
$r2 = $ua->simple_request(GET $u2);
}

#$headers1 = $r2->header('Client-SSL-Cipher');
#$headers2 = $r2->header('Client-SSL-Cert-Subject');
#$headers3 = $r2->header('Client-SSL-Cert-Issuer');
#$status = $r2->status_line;
#print "head1 $headers1 <br> head2 $headers2 <br> head3 $headers3 <br> ";
#print "status is $status";
#my $retry_html = $r2->content;
#print "$retry_html";

my $itemnum_page_html = $r2->content;

print "This should be the enter Iten Num page $itemnum_page_html ";
print 'this is directly after printing the page';

#---------------------------------------------------------------------------
---------------------
# We should now be on the "Enter an Item number page"
#---------------------------------------------------------------------------
---------------------
$itemnum_name = 'ItemNo';
$Got_To_Itemnum_Page = 'Add To Description';
$itemnum_page_html =~ s/\n/ /g; # Get rid of the linefeeds
$itemnum_page_html =~ s/\s+/ /g; # Compress spaces/tabs

#---------------------------------------------------------------------------
---------------------
# Find the Item Num input area and the submit button
#---------------------------------------------------------------------------
---------------------
print 'before parsing the form <br>';

@itemnum_forms =
HTML::Form->parse($itemnum_page_html,'http://cgi5.ebay.com/ws/') ;

print 'after parsing the form <br>'; # Never get here

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise