Using Crypt::SSLeay to post

Chris Brown <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
Hi,

I'm want to use LWP and Crypt::SSLeay to send an XML packet to a secure 
web server then get back and parse a response. I am doing this from 
behind a firewall. The code I'm working on is as follows:

#!/usr/bin/perl

use warnings;
use LWP::UserAgent;
use LWP::Debug qw(+);

#$ENV{HTTPS_PROXY} = 'xx.xx.xx.xx:xx';
$ENV{HTTPS_CERT_FILE} = '/tmp/test.pem';

my $xml=qq|<?xml version="1.0"?>
...
...|;

my $ua = LWP::UserAgent->new;
$ua->proxy(https  => 'xx.xx.xx.xx:xx');
my $req = HTTP::Request->new(POST => 'https://secure.server.com/test');
$req->content_type('text/xml');
$req->content($xml);
my $resp = $ua->request($req);
print $resp->as_string;

If I use LWP to set the proxy I get the following:

LWP::UserAgent::new: ()
LWP::UserAgent::proxy: https xx.xx.xx.xx:xx
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: POST https://secure.server.com/test
LWP::UserAgent::_need_proxy: Proxied to xx.xx.xx.xx:xx
LWP::UserAgent::request: Simple response: Not Implemented
501 Protocol scheme '' is not supported
Content-Type: text/plain
Client-Date: Sun, 23 Apr 2006 23:36:48 GMT
Client-Warning: Internal response

501 Protocol scheme '' is not supported

I'd appreciate advice on interpreting this response.

If I use Crypt::SSLeay to set the proxy I get error messages from the 
proxy saying that access is denied. I'm certain the proxy is set up to 
permit access to the secure server, so I don't understand this. Here's 
the response (I've removed the HTML)

LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: POST https://secure.server.com/test
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::UserAgent::request: Simple response: Internal Server Error

500 proxy connect failed: PROXY ERROR HEADER, could be non-SSL URL:
HTTP/1.0 403 Forbidden
Mime-Version: 1.0
Date: Mon, 24 Apr 2006 01:02:07 GMT
Content-Type: text/html
Content-Length: 1104
Expires: Mon, 24 Apr 2006 01:02:07 GMT
X-Squid-Error: ERR_ACCESS_DENIED 0
X-Cache: MISS from my.proxy.com
Proxy-Connection: close

ERROR
The requested URL could not be retrieved
While trying to retrieve the URL:
xx.xx.xx.xx:xx
The following error was encountered:
Access Denied.

Access control configuration prevents your request from
being allowed

==============================================

Without the proxy I get a peer certificate verification error.

Given my setup and requirements, is there any need to specify a 
certificate location? Shouldn't I be verifying the certificate sent by 
the server?

I am using perl 5.8.6, LWP 5.805, Crypt::SSLeay 0.51, and openssl 
0.9.7i. I'm running under Linux 2.4.26-1.2smp


Regards

Chris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.