I am trying to use LWP to log in to a SSL site. I have this code working on another SSL site, so the code shouldn't be too far off.
My first concern is that in the URL for the post there is a comment symbol (#). Is that an issue if I deference it? When I have "use strict" on I get this error:
Bareword "login" not allowed while "strict subs" in use at (eval 28) l +ine 18. Bareword "login" not allowed while "strict subs" in use at (eval 28) l +ine 18.
Line 18 is pointing to the POST line. When I take "use strict;" out I get the page hit, but an error. Here is the header and message returned from google:
HTTP/1.1 200 OK Connection: close Date: Fri, 14 Jun 2002 06:57:47 GMT Server: stronghold apache C2NetEU tomcat/1.0 Content-Type: text/html; charset=UTF-8 Client-Date: Fri, 14 Jun 2002 07:00:46 GMT Client-Response-Num: 1 Client-SSL-Cert-Issuer: /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Con +sulting cc/OU=Certification Services Division/CN=Thawte Server CA/Ema +il=server-certs@thawte.com Client-SSL-Cert-Subject: /C=US/ST=California/L=Mountain View/O=Google +Inc/CN=adwords.google.com Client-SSL-Cipher: EDH-RSA-DES-CBC3-SHA Client-SSL-Warning: Peer certificate not verified Client-Transfer-Encoding: chunked Link: ; rel="stylesheet" Servlet-Eng +ine: Tomcat Web Server/3.2 (final) (JSP 1.1; Servlet 2.2; Java 1.3.1_ +02; Linux 2.4.18-smp i386; java.vendor=Sun Microsystems Inc.) Set-Cookie: JSESSIONID=q93xd1cc51;Path=/select Set-Cookie2: JSESSIONID=q93xd1cc51;Version=1;Discard;Path="/select" Title: Google Adwords AdWords Select™ - It's All About Results™ Contact Us - Help Sorry, we're unable to process this request. There are two possible ca +uses for this error: You accessed this page via a bookmark instead of entering through the +AdWords Select homepage You have disabled cookies in your browser.

Is there a problem with getting the cookies? Is there a SSL certificate issue? Are they doing something weird on their end? Here is my code I am using to do this:
#!/usr/lib/perl -w #use strict; use LWP::UserAgent; use Crypt::SSLeay; use HTTP::Request::Common; use HTTP::Cookies; use LWP::Simple; my $ua = LWP::UserAgent->new; $ua->cookie_jar(HTTP::Cookies->new(file => 'cookie_jar', autosave =>1) +); push @{ $ua->requests_redirectable }, 'POST'; my $request = $ua->request(POST "https://adwords.google.com/select/mai +n", { login.userid => 'test@test.com', login.password => 'testabc', cmd => 'LoginValidation', login => 'Login', }); $b = $request->as_string; print "$b\n";

Any help is appreciated. Thanks!

Michael Jensen
michael at inshift.com
http://www.inshift.com

In reply to Error in SSL login via LWP by inblosam

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.