Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Digest Authentication encoding issue

by Nik (Initiate)
on Mar 18, 2008 at 18:37 UTC ( [id://674850]=perlquestion: print w/replies, xml ) Need Help??

Nik has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks, When i try the following code from cmd
htdigest -c "C:\path\passfile" "Δημιου&# +961;γία Βάσης Δε&#9 +48;ομένων!" webmaster
console understand it as Adding password for webmaster in realm ╬Φ╬╖╬╝╬╣╬┐╧Ζ╧Β╬│╬ψ╬▒ ╬Τ╬υ╧Δ╬╖╧Γ ╬Φ╬╡╬┤╬┐╬ ╝╬φ╬╜╧Κ╬╜!. as a result not a proper md5 crypt of the realm resultign to a faulty authentication

What can i do? Sorry for this not beign a perl questiosn i tried other forums but i though of askignj this here perhaps to see if i can a result by trying the same thing from within a perl script file. But wont ti also use dos to take place like? in backticks still wotn work:  print `htdigest -c "C:\path\passfile" "Δημιουργία Βάσης Δεδομένων!" webmaster so what's left?

Replies are listed 'Best First'.
Re: Digest Authentication encoding issue
by davido (Cardinal) on Mar 19, 2008 at 01:48 UTC

    so what's left?

    Throwing your hands up into the air and running out of the room with your hair on fire, hoping to douse it in a bucket of ice water before it explodes like the little spacemen in Mars Attacks!

    ...on second thought, maybe that won't help.

    Sorry I couldn't give a relevant answer. The question is far enough off-topic here that I have nothing to contribute other than a little imagery.


    Dave

      Here is what i my attempt to do the same thing through a cgi perl script using the Digest::MD5 module
      open FILE, ">>$ENV{'DOCUMENT_ROOT'}/some_path/some_other_path/some_pas +s_file" or die $!; print FILE "webmaster:Δημιουρ&#9 +47;ία Βάσης Δεδ&#95 +9;μένων!:" .Digest::MD5::md5_hex("a +dmin:Δημιουργία &#9 +14;άσης Δεδομέ&#957 +;ων!:this_is_the_pass") ."\n"; close FILE;
      But when it comes to authentication when i enter the credentials apache says there are wrong.
      An encoding issue again? the init.pl file which the above code resides is encoded in 'UTF-8'.

      Please suggest something else than hitting my head on the wall ;)

      A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Digest Authentication encoding issue
by chromatic (Archbishop) on Mar 20, 2008 at 22:43 UTC

    Is your password really Δημ...? (I doubt it.) If that's not your password, then storing the HTML encoded version of your password isn't going to work at all. You need to store your actual password.

    If you're not including your password in HTML, don't run it through HTML encoding. You can't just pick a random encoding to encode your password and expect everything else to recognize the encoding. Encodings don't work that way.

      Hello Chromatic,

      You must be talking about my first post when i was trying the digest method through windows shell(cmd)
      That didn't work because windows shell cant recognize greek in console
      Please check out this post http://perlmonks.org/?node_id=674993 where i'm trying to do the same thing with the help of Digest::MD5 module and see please if you cna help me there.

      Thank you

Re: Digest Authentication encoding issue
by ikegami (Patriarch) on Mar 21, 2008 at 11:16 UTC
    The first order of business would be find out in what encoding your web server expects the passwords to be in the password file. Come back after you find out the answer to that decidedly non-Perl question.
      Very good idea i have googled for that to find out what encoding apache wants the passwords to be but i didnt find any relevant info

      So you are saying that inside my perl script iam currently creating the passwords as utf-8 but apache expect a different character set?

      But hold on....by seeign the following code how can i be sure the password file being created will stored contents in utf-8 format?

      open FILE, ">$ENV{'DOCUMENT_ROOT'}/some_path/some_other_path/some_pass +_file" or die $!; print FILE "webmaster:realm made by greek chars!:" .Digest::MD5::m +d5_hex("webmaster:realm made by greek chars!:password") ."\n"; close FILE;
      Is it because the init.pl scripts has this line print header( -charset=>'utf-8' ); means that every text and every file created by init.pl will be stored as utf-8 too?

      UPDATE: BASED on http://people.apache.org/~drtr/charsets.html i beleive apache expects them only in ISO 8859-1 if i understood the site correctly but please check it too.

      Based on that assumption i did try this:

      open FILE, ">:encoding(iso-8859-1)", "$ENV{'DOCUMENT_ROOT'}/some_path/ +some_other_path/some_pass_file" or die $!; print FILE "webmaster:realm made by greek chars!:" .Digest::MD5::m +d5_hex("webmaster:realm made by greek chars!:password") ."\n"; close FILE;
      The idea is to force the contents of the newly created file that contains the passwords that Apache checks to be stored as latin1-iso, but unfortunately that didnt work either.

      Now that i think of it my realm contains greek chars and i tell perl to store them in the passowrd file as latin1-iso, but thats impossible right? Either that is the problem now or the apache doesnt excpect the encoding toi be iso-8859-1

      I really did my best to solve this problem so now i deserve to hear from you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://674850]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-18 06:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found