Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

A tale of LWP::UserAgent, Crypt::SSLeay and mod_perl

by skyknight (Hermit)
on Feb 10, 2006 at 02:25 UTC ( #529263=perlquestion: print w/replies, xml ) Need Help??

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

I'm struggling with the very vexing problem of having a snippet of code that works fine when invoked in a stand-alone process but does not work within the context of a mod_perl handler. Said snippet invokes an https request with LWP::UserAgent (using an HTTP::Request), and has $ENV{HTTPS_CA_FILE} set to a CA bundle file to trigger server certificate validation. In the stand-alone program I get back a response code from LWP::UserAgent of 200 if the cert was validated and 500 if it was not. In the mod_perl handler the code always returns 200, apparently never bothering with the CA bundle at all. I verified this by using strace. The stand-alone program opens the bundle but the mod_perl handler does not. Additionally strace shows the mod_perl handler successfully opening and

Even more interesting is that if I invoke the program version of the code via backticks from the mod_perl handler it works, so it can't possibly be a permissions issue within the web server. The only thing I can fathom is that somehow the Perl I'm getting for a stand-alone process is in some subtle way different from the Perl for which mod_perl was built, but both report 5.8.0 as their version. I've tried every sanity check and comparison my poor brain can muster, but I'm totally stumped and ready to surrender.

What could possibly be causing an identical code snippet to behave differently in these two contexts? I've printed out %ENV and it is as I expect. Could there be a binary incompabibility somewhere? A different library path configuration? I have never been more perplexed.

  • Comment on A tale of LWP::UserAgent, Crypt::SSLeay and mod_perl

Replies are listed 'Best First'.
Re: A tale of LWP::UserAgent, Crypt::SSLeay and mod_perl
by perrin (Chancellor) on Feb 10, 2006 at 03:24 UTC
    Have you checked to see if that environment variable is set in your mod_perl program? You may have to use PerlPassEnv or something similar. You should also check the permissions to make sure the user your mod_perl server runs as can read that file, although the backticks experiment would point to yes.
      As I mentioned, I dumped the contents of %ENV and it indeed contains what I expect. Also, I've tried setting it in the body of the handler package, in the handler method, and in the Apache config file.
        I'd suggest using the debugger on it at this point. Then you'll be able to see why it isn't taking the branch you expect it to.
Re: A tale of LWP::UserAgent, Crypt::SSLeay and mod_perl
by spiritway (Vicar) on Feb 10, 2006 at 05:47 UTC

    It might be useful for you to post the actual snippet. There might be a simple explanation that someone might spot right away if they could see the code.

    Or not...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://529263]
Approved by data64
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2019-06-18 13:24 GMT
Find Nodes?
    Voting Booth?
    Is there a future for codeless software?

    Results (81 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!