cURL + OpenSSL + PHP not working

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Fortune

    cURL + OpenSSL + PHP not working

    # uname -a
    Linux stargate.mxc-online.net 2.4.20-021stab022.2.77 7-smp #1 SMP Wed Jul 28
    17:12:37
    MSD 2004 i686 i686 i386 GNU/Linux

    I recompiled PHP with mcrypt, openssl, and curl
    phpinfo(): http://www.canadiandropshipping.com/hello.php3

    Does anyone know why this ssl curl test fails?
    http://www.canadiandropshipping.com...t/diag_curl.php
    it hangs on curl_exec(). I posted the code below.

    Here is the easyapache config I used. It compiled without errors. Did I miss
    something? Are there known issues with this combination of software?

    /scripts/easyapache


    +----------------------- Main Menu ------------------------+
    ¦ +------------------------------------------------------+ ¦
    ¦ ¦[ ] Apache 2 Support (Experimental & Very Broken, Not
    ¦ ¦[*] Expires Module
    ¦ ¦[*] Raise FD_SETSIZE to 16384 (System Wide)
    ¦ ¦[*] Prevent Users from reading other webroots
    ¦ ¦[*] Frontpage Module
    ¦ ¦[ ] Gzip Module (experimental)
    ¦ ¦[*] Raise HARD_SERVER_LIM IT
    ¦ ¦[ ] Perl Module (not required to run .cgi scripts/not
    ¦ ¦Php Module --->
    ¦ ¦[ ] PHP suEXEC Support
    ¦ ¦[*] Report Build Errors to cPanel
    ¦ ¦[ ] Reset Apache Config to Default (last resort)
    ¦ ¦[*] Rewrite Module
    ¦ ¦[ ] Skip Apache Build if up to date
    ¦ ¦[*] SSL Module
    ¦ ¦[*] suEXEC Module
    ¦ ¦[ ] Verbose Build (show configure and gcc output)
    ¦ +------------------------------------------------------+ ¦
    +----------------------------------------------------------+







    +-------------------- Php Module Menu ---------------------+
    ¦ +------------------------------------------------------+ ¦
    ¦ ¦[*] Php Module
    ¦ ¦ (*) Version 4.3.10
    ¦ ¦ ( ) Version 4.3.8
    ¦ ¦ ( ) Version 4.3.9
    ¦ ¦ ( ) Version 5.0.2 (TESTING)
    ¦ ¦ ( ) Version 5.0.3 (TESTING)
    ¦ ¦ (*) Bc Math
    ¦ ¦ (*) Calendar Support
    ¦ ¦ (*) Curl
    ¦ ¦ (*) Curl SSL Support
    ¦ ¦ (*) Dom XSLT
    ¦ ¦ ( ) Exif
    ¦ ¦ ( ) Flash
    ¦ ¦ (*) FTP
    ¦ ¦ (*) GD
    ¦ ¦ ( ) GetText
    ¦ ¦ ( ) Iconv (experimental)
    ¦ ¦ ( ) Imap Module
    ¦ ¦ ( ) Java (must already be installed, or install w
    ¦ ¦ ( ) Mb String
    ¦ ¦ (*) Mcrypt
    ¦ ¦ ( ) Memory Limit (experimental)
    ¦ ¦ ( ) Mhash
    ¦ ¦ ( ) Ming Support
    ¦ ¦ (*) Magic Quotes
    ¦ ¦ (*) Mysql Module
    ¦ ¦ (*) Openssl Support
    ¦ ¦ (*) Discard Path
    ¦ ¦ ( ) PDFlib (requires license for commerical use;
    ¦ ¦ (*) Pear
    ¦ ¦ ( ) Postgresql (will break 7.2.x or earlier, plea
    ¦ ¦ ( ) Pspell Module
    ¦ ¦ ( ) Sablot XSLT [may cause problems with chili!as
    ¦ ¦ ( ) SafeMode
    ¦ ¦ (*) Sockets
    ¦ ¦ ( ) Use System Mysql
    ¦ ¦ (*) Track Vars
    ¦ ¦ ( ) Freetype Support
    ¦ ¦ (*) Versioning
    ¦ ¦ ( ) WDDX
    ¦ ¦ ( ) XML RPC
    ¦ ¦ ( ) Zip
    ¦ ¦ (*) Zlib
    ¦ +------------------------------------------------------+ ¦
    +----------------------------------------------------------¦


    PHP Code:
    <?
    /*
    file created on 2/23/2004 to test CURL
    */

    function ssl_connect($ur l,$variables=0, $parse_variable s=0,$
    test=0,$timeout =30,$no_headers =0){
    global $SC;
    define(UMURL,$u rl);
    define(UMTIMEOU T,$timeout);

    // check for presence of CURL
    if (!function_exis ts("curl_init") ){
    // only display CURL error message if it hasn't been displayed
    before
    if (!$SC['no_curl']) print "\n<!-- Squirrelcart Error: You are using
    a service which requires CURL, and it is not enabled on your web
    server. -->";
    $SC['no_curl'] = 1;
    return;
    }
    // if URL has https in it, check for presence of OpenSSL

    $ch = curl_init(UMURL );

    // set some options for the connection
    curl_setopt($ch , CURLOPT_HEADER, 1);
    curl_setopt($ch ,CURLOPT_TIMEOU T,UMTIMEOUT);
    curl_setopt($ch ,CURLOPT_RETURN TRANSFER,1);
    if (strtoupper(sub str(PHP_OS,0,3) ) == 'WIN') {
    curl_setopt($ch , CURLOPT_SSL_VER IFYPEER, FALSE); // this line fixes
    SSL communications on some Windows servers (IIS 5.0?)
    }


    //curl_setopt($ch ,CURLOPT_VERBOS E,1);


    // attach the data
    //print "query is $query<br>";

    // run the transfer
    $result=curl_ex ec ($ch);
    if(curl_errno($ ch) > 0) echo "<p style='color: red'><b>cURL
    ERROR#".curl_er rno($ch).": ".curl_error($c h)." at ".__LINE__. " in
    ".__FILE__. "</b></p>";
    curl_close ($ch);
    return $result;
    }


    print "<html><head><t itle>CURL Test Page</title></head><body
    style=\"font-family: verdana, helvetica, tahoma; font-size: 12pt\"><b>CURL
    Test Page</b><br><br>To test a regular HTTP connection via curl to
    http://www.ebay.com,
    <br>
    <a href=\"?method= normal\">click here</a><br><br>
    ";
    print "To test a secure HTTPS (SSL) connection via curl to

    <br>
    <a href=\"?method= secure\">click here</a><br>";


    if ($HTTP_GET_VARS['method']) {
    print "<br><b>If a page is displayed below, the test worked. Do not
    worry about broken image tags. As long as you have some output from the page
    below the test is valid:</b><hr width=\"100%\" height=\"2\"><b r><br>";

    if ($HTTP_GET_VARS['method'] == "normal") $page = "http://www.ebay.com";
    if ($HTTP_GET_VARS['method'] == "secure") $page =
    "https://adwords.google. com/select/";
    $page_data = ssl_connect($pa ge);
    print $page_data;
    }

    print "</body></html>";

    ?>





  • Tex John

    #2
    Re: cURL + OpenSSL + PHP not working

    Your test link is still broken and your email address still doesn't work.
    I've tried to help -- again -- but can't so I'll repeat what I said before:
    are you sure curl is compiled into apache? And that all this is going to
    work with easyapache?

    John

    "Chris Fortune" <hey.spammer... just.get@job.or g> wrote in message
    news:Oo73e.1050 01$KI2.7292@clg rps12...[color=blue]
    > # uname -a
    > Linux stargate.mxc-online.net 2.4.20-021stab022.2.77 7-smp #1 SMP Wed Jul[/color]
    28[color=blue]
    > 17:12:37
    > MSD 2004 i686 i686 i386 GNU/Linux
    >
    > I recompiled PHP with mcrypt, openssl, and curl
    > phpinfo(): http://www.canadiandropshipping.com/hello.php3
    >
    > Does anyone know why this ssl curl test fails?
    > http://www.canadiandropshipping.com...t/diag_curl.php
    > it hangs on curl_exec(). I posted the code below.
    >
    > Here is the easyapache config I used. It compiled without errors. Did I[/color]
    miss[color=blue]
    > something? Are there known issues with this combination of software?
    >
    > /scripts/easyapache
    >
    >
    > +----------------------- Main Menu ------------------------+
    > ¦ +------------------------------------------------------+ ¦
    > ¦ ¦[ ] Apache 2 Support (Experimental & Very Broken, Not
    > ¦ ¦[*] Expires Module
    > ¦ ¦[*] Raise FD_SETSIZE to 16384 (System Wide)
    > ¦ ¦[*] Prevent Users from reading other webroots
    > ¦ ¦[*] Frontpage Module
    > ¦ ¦[ ] Gzip Module (experimental)
    > ¦ ¦[*] Raise HARD_SERVER_LIM IT
    > ¦ ¦[ ] Perl Module (not required to run .cgi scripts/not
    > ¦ ¦Php Module --->
    > ¦ ¦[ ] PHP suEXEC Support
    > ¦ ¦[*] Report Build Errors to cPanel
    > ¦ ¦[ ] Reset Apache Config to Default (last resort)
    > ¦ ¦[*] Rewrite Module
    > ¦ ¦[ ] Skip Apache Build if up to date
    > ¦ ¦[*] SSL Module
    > ¦ ¦[*] suEXEC Module
    > ¦ ¦[ ] Verbose Build (show configure and gcc output)
    > ¦ +------------------------------------------------------+ ¦
    > +----------------------------------------------------------+
    >
    >
    >
    >
    >
    >
    >
    > +-------------------- Php Module Menu ---------------------+
    > ¦ +------------------------------------------------------+ ¦
    > ¦ ¦[*] Php Module
    > ¦ ¦ (*) Version 4.3.10
    > ¦ ¦ ( ) Version 4.3.8
    > ¦ ¦ ( ) Version 4.3.9
    > ¦ ¦ ( ) Version 5.0.2 (TESTING)
    > ¦ ¦ ( ) Version 5.0.3 (TESTING)
    > ¦ ¦ (*) Bc Math
    > ¦ ¦ (*) Calendar Support
    > ¦ ¦ (*) Curl
    > ¦ ¦ (*) Curl SSL Support
    > ¦ ¦ (*) Dom XSLT
    > ¦ ¦ ( ) Exif
    > ¦ ¦ ( ) Flash
    > ¦ ¦ (*) FTP
    > ¦ ¦ (*) GD
    > ¦ ¦ ( ) GetText
    > ¦ ¦ ( ) Iconv (experimental)
    > ¦ ¦ ( ) Imap Module
    > ¦ ¦ ( ) Java (must already be installed, or install w
    > ¦ ¦ ( ) Mb String
    > ¦ ¦ (*) Mcrypt
    > ¦ ¦ ( ) Memory Limit (experimental)
    > ¦ ¦ ( ) Mhash
    > ¦ ¦ ( ) Ming Support
    > ¦ ¦ (*) Magic Quotes
    > ¦ ¦ (*) Mysql Module
    > ¦ ¦ (*) Openssl Support
    > ¦ ¦ (*) Discard Path
    > ¦ ¦ ( ) PDFlib (requires license for commerical use;
    > ¦ ¦ (*) Pear
    > ¦ ¦ ( ) Postgresql (will break 7.2.x or earlier, plea
    > ¦ ¦ ( ) Pspell Module
    > ¦ ¦ ( ) Sablot XSLT [may cause problems with chili!as
    > ¦ ¦ ( ) SafeMode
    > ¦ ¦ (*) Sockets
    > ¦ ¦ ( ) Use System Mysql
    > ¦ ¦ (*) Track Vars
    > ¦ ¦ ( ) Freetype Support
    > ¦ ¦ (*) Versioning
    > ¦ ¦ ( ) WDDX
    > ¦ ¦ ( ) XML RPC
    > ¦ ¦ ( ) Zip
    > ¦ ¦ (*) Zlib
    > ¦ +------------------------------------------------------+ ¦
    > +----------------------------------------------------------¦
    >
    >
    > PHP Code:
    > <?
    > /*
    > file created on 2/23/2004 to test CURL
    > */
    >
    > function ssl_connect($ur l,$variables=0, $parse_variable s=0,$
    > test=0,$timeout =30,$no_headers =0){
    > global $SC;
    > define(UMURL,$u rl);
    > define(UMTIMEOU T,$timeout);
    >
    > // check for presence of CURL
    > if (!function_exis ts("curl_init") ){
    > // only display CURL error message if it hasn't been displayed
    > before
    > if (!$SC['no_curl']) print "\n<!-- Squirrelcart Error: You are[/color]
    using[color=blue]
    > a service which requires CURL, and it is not enabled on your web
    > server. -->";
    > $SC['no_curl'] = 1;
    > return;
    > }
    > // if URL has https in it, check for presence of OpenSSL
    >
    > $ch = curl_init(UMURL );
    >
    > // set some options for the connection
    > curl_setopt($ch , CURLOPT_HEADER, 1);
    > curl_setopt($ch ,CURLOPT_TIMEOU T,UMTIMEOUT);
    > curl_setopt($ch ,CURLOPT_RETURN TRANSFER,1);
    > if (strtoupper(sub str(PHP_OS,0,3) ) == 'WIN') {
    > curl_setopt($ch , CURLOPT_SSL_VER IFYPEER, FALSE); // this line fixes
    > SSL communications on some Windows servers (IIS 5.0?)
    > }
    >
    >
    > //curl_setopt($ch ,CURLOPT_VERBOS E,1);
    >
    >
    > // attach the data
    > //print "query is $query<br>";
    >
    > // run the transfer
    > $result=curl_ex ec ($ch);
    > if(curl_errno($ ch) > 0) echo "<p style='color: red'><b>cURL
    > ERROR#".curl_er rno($ch).": ".curl_error($c h)." at ".__LINE__. " in
    > ".__FILE__. "</b></p>";
    > curl_close ($ch);
    > return $result;
    > }
    >
    >
    > print "<html><head><t itle>CURL Test Page</title></head><body
    > style=\"font-family: verdana, helvetica, tahoma; font-size: 12pt\"><b>CURL
    > Test Page</b><br><br>To test a regular HTTP connection via curl to
    > http://www.ebay.com,
    > <br>
    > <a href=\"?method= normal\">click here</a><br><br>
    > ";
    > print "To test a secure HTTPS (SSL) connection via curl to
    > https://adwords.google.com/select/
    > <br>
    > <a href=\"?method= secure\">click here</a><br>";
    >
    >
    > if ($HTTP_GET_VARS['method']) {
    > print "<br><b>If a page is displayed below, the test worked. Do not
    > worry about broken image tags. As long as you have some output from the[/color]
    page[color=blue]
    > below the test is valid:</b><hr width=\"100%\" height=\"2\"><b r><br>";
    >
    > if ($HTTP_GET_VARS['method'] == "normal") $page =[/color]
    "http://www.ebay.com";[color=blue]
    > if ($HTTP_GET_VARS['method'] == "secure") $page =
    > "https://adwords.google. com/select/";
    > $page_data = ssl_connect($pa ge);
    > print $page_data;
    > }
    >
    > print "</body></html>";
    >
    > ?>
    >
    >
    >
    >
    >[/color]


    Comment

    • Chris Fortune

      #3
      Re: cURL + OpenSSL + PHP not working

      Hello Tex John,

      The test URL is here:

      strange, the mailing list software seemed to abbreviated it.

      How do I test if curl is compiled into apache?

      Thanks for your help.

      Chris


      Comment

      • Tex John

        #4
        Re: cURL + OpenSSL + PHP not working


        "Chris Fortune" <hey.spammer... just.get@job.or g> wrote in message
        news:hqt3e.1274 66$ZO2.112422@e dtnps84...[color=blue]
        > Hello Tex John,
        >
        > The test URL is here:
        > http://www.canadiandropshipping.com/.../diag_curl.php
        > strange, the mailing list software seemed to abbreviated it.
        >
        > How do I test if curl is compiled into apache?
        >
        > Thanks for your help.
        >
        > Chris
        >[/color]

        This works fine on my box (where I just had PHP and Apache recompiled with
        curl and openssl).

        Well, the first one works so curl works. The other one times out so never
        gets around to throwing the curl error. You can try upping your curl timeout
        to see if you can get to an error, but I suspect that won't help. Smells
        like a server problem.

        Something else I would suggest you check is that that outgoing port is open
        all the way to the net. Firewalls, routers....

        Do you have any SSL certs correctly installed and running which would
        indicate SSL was fully functional in Apache? Maybe you can get an idea or
        two from here:



        You may need to switch to a server NG since it looks like PHP is ok unless
        something funny is going on with your openssl install.


        Comment

        Working...