jnofzinger has asked for the wisdom of the Perl Monks concerning the following question:

I have been using WWW::Mechanize for several months to gather information from a secure website. On 1/8/11, the certificate expired. I replaced the cert with the new one and I now am unable to get logged in. Occasionally, it will log in, but when I go to the next page i need, it's back to the login screen again.
#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; use HTTP::Cookies; use Crypt::SSLeay; my $cookie_jar = HTTP::Cookies->new(file => 'cookie', autosave=>1, ign +ore_discard => 1); my $agent = WWW::Mechanize->new(cookie_jar => $cookie_jar, autocheck = +> 0); $ENV{HTTPS_CA_DIR} = 'cert/'; my $user = 'xxxx'; my $pass = 'xxxx'; $url = 'https://psmsadmin.vzw.com/vzw-scat-ui/Welcome.do'; $agent->get($url); $agent->form_name('loginForm'); $agent->set_fields( userId => $user, password => $pass ); $agent->submit(); print $agent->{content}; $agent->form_name('groupForm'); $agent->submit();

Replies are listed 'Best First'.
Re: Perl Mechanize login issue
by Gangabass (Vicar) on Jan 13, 2011 at 00:38 UTC

    Are you sure this is cert issue and not some kind of JavaScript issue? It's very hard to help you with this question so you need to debug it by yourself.

    Did you try to login via browser with JavaScript disabled? Is it OK?

    Also you can look at the HTTT headers (i use HttpFox add on for Firefox for this) and try to repeat this headers in your script.

      I turned off js on my browser and it doesn't work and that's because it does a redirect after the login. I have already accommodated for the redirect in my code and this was working up until the day after the cert expired.
      <html> <body onload="javascript:submitAction();"> <form name="groupForm" method="post" action="/vzw-scat-ui/RedirectToGr +oup.do"><div><input type="hidden" name="org.apache.struts.taglib.html +.TOKEN" value="d61fa121c70d93339c7bc8fe53936299"></div> </form> </body> <script language="JavaScript"><!-- function submitAction(){ document.forms[0].submit(); } //--></script>

        So you just make a redirect after login or submit this second hidden redirect form?