Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: SSL support for fsockopen

  1. #1
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default SSL support for fsockopen

    I'm trying to get an SSL connection using fsockopen but it's giving me this error.

    Quote Originally Posted by PHP error
    Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://www.domain.com:443 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in [__my path__] on line 291
    Here's my fsockopen code:

    PHP Code:
    function sendToHost($host,$port=80,$method,$path,$data,$useragent=0)
    {
        
    $buf='';
        
    // Supply a default method of GET if the one passed was empty
        
    if (empty($method)) {
            
    $method 'GET';
        }
        
    $method strtoupper($method);
        
    $fp fsockopen($host$port,$errNo,$errStr);
        if (!
    $fp)    {
            die(
    '<div class="error"><strong>PHP:</strong> Error connecting to '.$host.'</div>');
        }
        if (
    $method == 'GET') {
            
    $path .= '?' $data;
        }
        
    fputs($fp"$method $path HTTP/1.1\r\n");
        
    fputs($fp"Host: $host\r\n");
        
    fputs($fp,"Content-type: application/x-www-form- urlencoded\r\n");
        
    fputs($fp"Content-length: " strlen($data) . "\r\n");
        if (
    $useragent) {
            
    fputs($fp"User-Agent: MSIE\r\n");
        }
        
    fputs($fp"Connection: close\r\n\r\n");
        if (
    $method == 'POST') {
            
    fputs($fp$data);
        }

        while (!
    feof($fp)) {
            
    $buf .= fgets($fp,128);
        }
        
    fclose($fp);
        if (empty(
    $errStr))    {
            return 
    $buf;
        }
        else    {
            return 
    $errStr;
        }

    Normal HTTP connections work, but not HTTPS connections. It says I need to configure it in PHP, but I don't know where to start.

    I'm lost.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  2. #2
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  3. #3
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Same error.

    Oh, and BTW, here's how I use the function:

    PHP Code:
    echo sendToHost('ssl://www.domain.com/',443,'POST','/index.php',''); 
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Well, there's nothing wrong with the function; but if you need to get rid of the trailing slash on the host name in the last code you posted. I have not received that error that you describe in your first post, but I did receive a Bad Request error (connecting to paypal.com using ssl on port 443). I will look at my php.ini file to see what there could be in there that would make it show that error.

    Hope this helps for now.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Hm... Thanks. I'm still having the same error though.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  6. #6
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Just a quick question; are you on a windows or a linux server and what version of php do you have installed? Either way; if you have php4, ssl will not work with fsockopen; however, if you have php5, you need to have the openssl module installed/enabled.

    Hope this helps.

    Edit:
    check the following websites to get more information:

    http://www.google.com/search?q=Unabl...ient=firefox-a
    Last edited by thetestingsite; 12-02-2007 at 03:07 AM. Reason: added link to google search
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #7
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    I'm developing this thing on a Windows server, but moving it into a Linux server. Both have PHP5 installed with OpenSSL.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  8. #8
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Not sure then. All of the documentation and whatnot state that you have to have the OpenSSL php module enabled for it (ssl connection using fsockopen) to work properly. Other than what I have stated above, I have no idea.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  9. #9
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Yeah. It's strange. Here's my phpinfo() output if anyone's interested.
    http://home.alotofstuffhere.com/phpinfo.php
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  10. #10
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Ok, it looks as if you do not have the openssl module for php installed/enabled. Take a look at my phpinfo and compare. If you are running it on a Windows server (I assume you are using a WAMP server program on your personal computer), you will have to enable it in your php.ini file. It would be under extension=openssl.dll (Windows) or extension=openssl.so (Linux).

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •