RewriteMap Perl script different result on manual execution

Oh, the strange things mod_rewrite does!

RewriteMap Perl script different result on manual execution

Postby rhb » Thu Sep 09, 2004 11:53 pm

Hello, I am finding that on the verified same input, the results are different when a Perl script is used as a RewriteMap as compared with a similar stand-alone Perl script. How could I possibly get equal results? The differences solely arise with the use of the digest function, all other script parts work equally well. I confirmed that the digest function uses the same foo_new_key and receives the same input, at least seemingly - I wonder if string termination could play a role. Thanks & Greetings, Ralf

RewriteMap dnmap prg:/foo/dncert.pl
RewriteCond %{REQUEST_URI} .php$
RewriteCond %{LA-U:SSL_CLIENT_S_DN} (..*)
RewriteRule (.*) ${dnmap:%1} [C,NE]
RewriteRule (.*) - [E=SSLHANDLE:$1,C]
RewriteRule .* %{REQUEST_URI}

#!/usr/bin/perl
$| = 1;
#
# this script generates a 22 byte digest from the certificate's
# really long SSL_CLIENT_S_DN Distinguished Names, e.g.
# /C=DE/O=Foo Organization/OU=Foo Unit/CN=Foo Name
# would become with the help of this script
# FooName_AbCdEfGhIjKlMnOpRsTuVw
#
use Digest::HMAC_MD5 qw(hmac_md5);
#
while (<STDIN>) {
#
local $instd = $_;
#
$hmac = Digest::HMAC_MD5->new('foo_new_key');
$hmac->add($instd);
$inmd5 = $hmac->b64digest;
#
s|.*/CN=(.*)|$1|;
s|(.*)(/.*)|$1|;
s| ||;
#
s|(.{8})(.*)|$1_$inmd5|;
#
print $_;
}
rhb
 

Postby rhb » Fri Sep 10, 2004 12:02 am

Found out after a decent cup of coffee, sorry for the bandwidth: add line as shown below to remove NUL termination. Greetings, Ralf

[...]
local $instd = $_;
chomp $instd;
[...]
rhb
 


Return to Idiosyncrasies

Who is online

Users browsing this forum: No registered users and 3 guests

cron