For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > July 2006 > libwww-SSL UserAgent Post Issue









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author libwww-SSL UserAgent Post Issue
AZSTYX

2006-07-28, 6:59 pm

Hello Folks!

Environment:
libwww-perl: 5.805
Crypt::SSLeay -- 0.51
OS: Solaris 8
Perl: 5.8.4

Issue Summary:
Issue with SSL UserAgent POST operation.

I have a script that randomly fails against devices using HTTPS, which
have a known Certificate issue.
In repeated runs against the same host, it fails just about every other
time (every 2nd run).
It is fact that the host certificate needs to be re-generated with
proper hostname and ip address.
(We are currently ignoring these warnings when using IE browser to
access the host).
With the CA issue in mind, I suspect that the bad certs are what is
making the program fail.
I receive these types of messages:
StatusLine[500 Server closed connection without sending any data back]
Code[500] Message[Server closed connection without sending any data
back]
StatusLine[500 EOF] Code[500] Message[EOF]
Q: With that said, does LWP have a method of verifying a host Cert or
SSL issue?
Q: How can I debug this issue since it is not consistent?
Q: Is there another CPAN module I can use to check and validate the SSl
connection or certificate?

My script:

code:
#!/export/ieapps/common/perl5/perl-5.8.4/bin/perl # getwsd2.pl - LWP demo - downloads a radware WSD config ascii file. # utilizes HTTPS,login credentials and writes directly to external content file. # usage: lwpdemo.pl <devname> <devipaddr> <port> <uid> <passw> # output: /export/ieapps/local/test/<devName.asc> use strict; use warnings; use LWP; ######################################## ##### my $urlConfigFile = '/dynamic/File/Configuration/ReceivefromDevice' ; my $urlDeviceinfo = '/dynamic/Device/DeviceInformation'; my ($ua, $httpReq, $httpResp, $url, $baseUrl, $credUrl); my ($devName, $devIP, $port, $UID, $upassw); my ($statusLine, $statusCode, $statusMsg, $contentResponse); my $asciiFile = "/export/ieapps/local/test/"; ######################################## ######### if (@ARGV == 5) { # if there are 5 arguments $devName = $ARGV[0]; $devIP = $ARGV[1]; $port = $ARGV[2]; $UID = $ARGV[3]; $upassw = $ARGV[4]; } else { die "Error 01: Usage: $0 <devname> <devipaddr> <port> <uid> <passw>\n"; } print "Processing devName [$devName] ip addr [$devIP].\n"; print "Using libwww-perl-$LWP::VERSION\n"; $asciiFile .= "$devName.asc"; print "Output file is [$asciiFile].\n"; $baseUrl = "https://$devIP:$port"; # create base URL $credUrl = "$devIP:$port"; # create URL for credentials print "Base URL [$baseUrl]\n"; ######################################## ############################### # start LWP Processing ######################################## ################################# $ua = LWP::UserAgent->new; # create new user agent object $ua->timeout(15); # set user agent timeout to 15 seconds $url = "$baseUrl$urlDeviceinfo"; # set full url for device info print "Setting Credentials using credurl[$credUrl]\n"; $ua->credentials($credUrl,"Radware",$UID => $upassw); print "\n\nNow get the WSD config ascii file.\n"; $url = "$baseUrl$urlConfigFile"; # create URL for getting config ascii file print "Submitting browser request using url [$url].\n"; $httpResp = $ua->post($url, [DownloadFormat => 'ascii'], ':content_file' => $asciiFile); # save memory, write directly to file $statusLine = $httpResp->status_line(); $statusCode = $httpResp->code(); $statusMsg = $httpResp->message(); print "HTTP Response 2: StatusLine[$statusLine] Code[$statusCode] Message[$statusMsg]\n"; if ($httpResp->is_success) { print "Request OK.\n"; } else { die "Request failed.\n"; }



My run results:

code:
dsym03z>./getwsd1.pl device-b 10.10.10.20 1900 admin admin Processing devName [device-b] ip addr [10.10.10.20]. Using libwww-perl-5.805 Output file is [/export/ieapps/local/test/device-b.asc]. Base URL [https://10.10.10.20:1900] Setting Credentials using credurl[10.10.10.20:1900] Submitting initial browser request using url [https://10.10.10.20:1900/dynamic/De...viceInformation]. HTTP Response 1: StatusLine[200 OK] Code[200] Message[OK] Request OK. Results: Now get the WSD config ascii file. Submitting browser request using url [https://10.10.10.20:1900/dynamic/Fi...ceivefromDevice]. HTTP Response 2: StatusLine[500 EOF] Code[500] Message[EOF] Request failed.


I appreciate any comments or feedback on my issue!!
:)
Styx

Dr.Ruud

2006-07-28, 6:59 pm

AZSTYX schreef:

> $ua->timeout(15); # set user agent timeout to 15 seconds


Did you test with 30 or 60?

--
Affijn, Ruud

"Gewoon is een tijger."


AZSTYX

2006-07-28, 6:59 pm


Dr.Ruud wrote:
> AZSTYX schreef:
>
>
> Did you test with 30 or 60?
>
> --
> Affijn, Ruud
>
> "Gewoon is een tijger."


Hello, thx for the reply and info!
:)
Yes, I just tried with timeout(30) and 60 and got the same results.
thx,
Styx

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com