Uploading files to a HTTPS server - 501 error
Anonymous Monk
created: 2004-06-14 11:38:34
Hi

I finally managed to get the uploading of files to a HTTPS server working through a perl script run on the command line (thanks to perlmonks!!).

However, when I call the script via a browser, I get the error:

501 Protocol scheme 'https' is not supported (Crypt::SSLeay not installed)

I do have Crypt installed. The code for calling the perl script frmo the browser is

htp.formOpen(curl=>url,cmethod=>'POST');

The perl code is

my $browser = LWP::UserAgent->new;
 my $response = $browser->post($url, Content_Type => "multipart/form-data", Content => [FILE1 => [$filename]]);

Do I need to call the perl script in a different way from the browser if it is talking to a HTTPS server?

Thanks

Jonathan

Re: Uploading files to a HTTPS server - 501 error
created: 2004-06-14 12:15:43
How are running from the browser? The first snippet of code looks like JavaScript. Where is the Perl script running from? You can't run the Perl script from inside a browser with JavaScript. I am guessing that you can use JavaScript to make the browser do the upload.
Re^2: Uploading files to a HTTPS server - 501 error
created: 2004-06-15 08:18:03
I am running the perl script via a shell script which just calls the perl script. This works fine from the command line. If I take the actual post command out of the perl script, then it also works fine when being called from the browser (i.e. all messages are displayed correcty and the script completes). However, when the post is run via the browser, I get the 501 error.

The web server is on the same system as the scripts. The browser is on a PC.

I am wondering if it is having problems loading the Crypt::SSLeay module when run from the browser. If i explicitly load this with "use", then the program crashes with no error messages when run from the browser, but works when run from the command line.

This is how the shell script is called via the browser

htp.formOpen(curl=>
script_name.sh? file_name,cmethod=>'POST'); htp.formSubmit(NULL,'Upload Text File to Secure Server');
The script_name is the shell script which calls the perl script, and file_name is the file parameter to upload. The perl script gets the file_name paramter passed to it OK, as it can print it out

Maybe there is a better way of doing this directly from the browser, or maybe something needs configuring on the browser for https?

Thanks

Jonathan

Re^3: Uploading files to a HTTPS server - 501 error
created: 2004-06-15 18:41:13
What are you trying to accomplish? It looks like you are running JavaScript in the browser that posts to the shell script on the web server. I am going to guess that the shell script is not a CGI script. I am also going to bet that web server is not configured to run shell scripts as CGI scripts and gives the 501 error because it can't POST to them.

It is possible to have a CGI script (usually written all in Perl), that accepts a file upload and then POSTs it to another secure web server. I guess it is also possible to have a CGI script on a web server that POSTs a local file to a secure web server but I am not sure why you would want do that. If posting from a browser to the secure site is working, why do you need the script using LWP?

Re^4: Uploading files to a HTTPS server - 501 error
created: 2004-06-16 07:42:42
Got it working now!! - Interesting solution:-

Remember - the perl script was transferring the file correctly when run from the command line, but when the perl script was invoked from the browser I would get the error:

"501 Protocol scheme 'https' is not supported (Crypt::SSLeay not installed)"

Solution:- add the -T option (taint mode) to the perl script, so first line:

#!/usr/bin/perl -w

became:

#!/usr/bin/perl -wT

Not sure why this works - but it does!

Thanks for your help

Jonathan

Re: Uploading files to a HTTPS server - 501 error
created: 2004-06-15 08:23:03

When Perl/LWP says that Crypt::SSLeay is not installed, then, most likely, Crypt::SSLeay is not installed. There is no module Crypt, this is only a namespace in which some other modules live.

You will need to install Crypt::SSLeay and the corresponding XS libraries. The necessary libraries are available from http://www.openssl.org, and I believe the process is described in the README.SSL of LWP, the FAQ of WWW::Mechanize (which hints at having IO::Socket::SSL as an alternative) and also in the documentation of WWW::Mechanize::Shell.

Update: Fixed names to the actual parts of documentation

Re^2: Uploading files to a HTTPS server - 501 error
created: 2004-06-15 09:39:40
It is installed - here is the output from the script running from comand line:
Archive::Zip -- 1.05
Compress::Zlib -- 1.19
Crypt::SSLeay -- 0.51
DBD::Oracle -- 1.12
DBI -- 1.32
Digest::MD5 -- 2.30
HTML::Parser -- 3.34
HTML::Tagset -- 3.03
MIME::Base64 -- 2.21
Net -- ???
Net::SSLeay -- 1.25
Perl -- 5.6.0
URI -- 1.27
XML::Parser -- 2.30
XML::Parser::Expat -- 2.30
XML::Simple -- 1.05
libwww-perl -- ???

Transferring File to Secure Server
The filename is: XXtest8b.tst
The File was transferred succesfully
Looking at SSLeay.pm, it uses bootstrap:

require DynaLoader;
@ISA = qw(DynaLoader);
$VERSION = '0.51';
bootstrap Crypt::SSLeay $VERSION;
I'm wondering if the bootsrap is failing when running from the browser?

Thanks

Jonathan

perlmonks.org content © perlmonks.org and Anonymous Monk, Corion, iburrell

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03