"Alexander Zinniker" <[EMAIL PROTECTED]> writes: > Hello! > > I'm using OpenSSL 0.9.3b and Net:SSLeay 1.05 with Perl 5.005_03. I > have to connect to an SSL enabled server which also requires basic > autentication, get some pages and post some forms. I tried for many hours > now and it still does not work. There is no problem with the GET method, I > get all I want. > > But if I try to submit some form content using post_https, the form content > gets lost. I'm using the following script: > > --------------------------------------------------------------------- > #!/usr/bin/perl > > use Net::SSLeay qw(post_https get_https make_form make_headers); > use MIME::Base64 qw(encode_base64); > > ($page, $response, %reply_headers) > = post_https('myhost.com', 443, '/cgi-bin/alz.pl', > make_headers( > 'User-Agent' => 'Cryptozilla/5.0b1', > 'Authorization' => > "BASIC".encode_base64("myuser:mypasswd") ^ Missing a space here----------' > ), > make_form('val1' => 'open', > 'val2' => 'ssl')); > > print $page, "\n"; > print "Response:\n$response\n"; But then I noticed some other "problems" (not properly bugs in my code, but anyway...). It seems MIME::Base64::encode() adds a newline in the end, which causes things to be interpretted as if the HTTP headers ended right there. For GETs (by luck) this does not seem to be a problem, but for posts its fatal. Here's a snippet that works (and makes all this very visible). #!/usr/bin/perl # from mail by [EMAIL PROTECTED] # # Usage: examples/post_auth.pl user pw www.bacus.pt 443 /a/t.x use Net::SSLeay qw(post_https get_https make_form make_headers); use MIME::Base64 qw(encode_base64); ($user, $pw, $site, $port, $url) = @ARGV; $auth = 'BASIC '.encode_base64("$user:$pw"); warn ">$auth<\n"; chomp $auth; # get rid of the gratuitous newline $headers = make_headers('User-Agent' => 'Cryptozilla/5.0b1', 'Authorization' => $auth); warn ">>$headers<<\n"; $form = make_form('val1' => 'open', 'val2' => 'ssl'); warn ">>>$form<<<\n"; ($page, $response, %reply_headers) = post_https($site, $port, $url, $headers, $form); print $page, "\n"; print "Response:\n$response\n"; #EOF The make_headers() will work around this in version 1.06. For the time being here's a patched version of make_headers(): sub make_headers { my (@headers) = @_; my $headers; while (@headers) { my ($name, $data) = (shift(@headers), shift(@headers)); chomp $data; # MIME::Base64::encode adds a \n, chomp it, just in case $headers .= $name.': '.$data."\r\n"; } return $headers; } --Sampo ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]