Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: SSL support for fsockopen

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

    Default

    Can you point me to where I can find the openssl.dll? It's not even in my php.ini file. Thanks.
    And I installed everything separately, it wasn't a package.
    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. #12
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Quote Originally Posted by http://php.net/openssl
    Note: Note to Win32 Users In order for this extension to work, there are DLL files that must be available to the Windows system PATH. See the FAQ titled "How do I add my PHP directory to the PATH on Windows" for information on how to do this. Although copying DLL files from the PHP folder into the Windows system directory also works (because the system directory is by default in the systems PATH), it is not recommended. This extension requires the following files to be in the PATH: libeay32.dll
    Additionally, if you are planning to use the key generation and certificate signing functions, you will need to install a valid openssl.cnf on your system. As of PHP 4.3.0, we include a sample configuration file in the openssl folder of our win32 binary distribution. If you are using PHP 4.2.0 or later and are missing the file, you can obtain it from » the OpenSSL home page or by downloading the PHP 4.3.0 release and using the configuration file from there. PHP will search for the openssl.cnf using the following logic:

    * the OPENSSL_CONF environmental variable, if set, will be used as the path (including filename) of the configuration file.
    * the SSLEAY_CONF environmental variable, if set, will be used as the path (including filename) of the configuration file.
    * The file openssl.cnf will be assumed to be found in the default certificate area, as configured at the time that the openssl DLL was compiled. This is usually means that the default filename is c:\usr\local\ssl\openssl.cnf.


    In your installation, you need to decide whether to install the configuration file at c:\usr\local\ssl\openssl.cnf or whether to install it someplace else and use environmental variables (possibly on a per-virtual-host basis) to locate the configuration file. Note that it is possible to override the default path from the script using the configargs of the functions that require a configuration file.
    Hope this helps.

    Edit:
    or you can view the installation faq: http://www.php.net/manual/en/faq.ins...tion.addtopath
    "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

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

    Default

    Where can I find the DLL files?

    Edit: Nevermind. Got a non-developer version of PHP and it had all the DLL's.
    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. #14
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    It's been a little while since I installed PHP on a Windows machine, but I believe it is in the PHP_ROOT_DIR extensions folder or something to that effect. But, being that you are on a Windows machine, you can do a search for openssl using the "Search" function.

    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

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

    Default

    Hm.. this looks like fun.

    Quote Originally Posted by README_SSL.txt
    To use the CSR and key generation functions from PHP, you will need to install
    an openssl.cnf file. We have included a sample file that can be used for this
    purpose in this folder alongside this readme file.

    The default path for the openssl.cnf file is determined as follows:

    OPENSSL_CONF environmental variable, if set, is assumed to hold the
    path to the file.

    If it is not set, SSLEAY_CONF environmental variable is checked next.
    If neither are set, PHP will look in the default certificate area that was set
    at the time that the SSL DLLs were compiled. This is typically
    "C:\usr\local\ssl\openssl.cnf".

    If the default path is not suitable for your system, you can set the
    OPENSSL_CONF variable; under windows 95 and 98 you can set this variable in
    your autoexec.bat (or the batch file that starts your webserver/PHP).
    Under NT, 2000 and XP you can set environmental variables using "My Computer"
    properties.

    If setting an environmental var is not suitable, and you don't want to install
    the config file at the default location, you can override the default path
    using code like this:

    $configargs = array(
    "config" => "path/to/openssl.cnf"
    );

    $pkey = openssl_pkey_new($config);
    $csr = openssl_csr_new($dn, $pkey, $config);

    Please consult the online manual for more information about these functions.

    NOTE!

    Windows Explorer gives special meaning to files with a .cnf extension.
    This typically means that editing the file from the explorer (by double or
    right-clicking) will be difficult or impossible depending on your setup.
    It is often easier to open the file from within the editor.
    You can avoid this issue by naming the file something else (you might need to
    rename the file using a DOS box) and then setting up an environmental variable
    as described above.
    (For anyone else going through the same trouble as I am)
    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. #16
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Where can I find my openssl.cnf anyway?

    Oh, and here's even more debug info:

    [Sun Dec 02 14:31:53 2007] [notice] Parent: Created child process 3016
    [Sun Dec 02 14:31:54 2007] [notice] Child 5972: Released the start mutex
    PHP Warning: PHP Startup: openssl: Unable to initialize module\nModule compiled with module API=20060613, debug=0, thread-safety=1\nPHP compiled with module API=20071006, debug=0, thread-safety=1\nThese options need to match\n in Unknown on line 0
    [Sun Dec 02 14:31:54 2007] [notice] Child 3016: Child process is running
    [Sun Dec 02 14:31:54 2007] [notice] Child 3016: Acquired the start mutex.
    [Sun Dec 02 14:31:54 2007] [notice] Child 3016: Starting 250 worker threads.
    [Sun Dec 02 14:31:54 2007] [notice] Child 3016: Starting thread to listen on port 443.
    [Sun Dec 02 14:31:54 2007] [notice] Child 3016: Starting thread to listen on port 80.
    [Sun Dec 02 14:31:55 2007] [notice] Child 5972: Waiting for 250 worker threads to exit.
    [Sun Dec 02 14:31:55 2007] [notice] Child 5972: All worker threads have exited.
    Error in my_thread_global_end(): 1 threads didn't exit
    [Sun Dec 02 14:32:00 2007] [notice] Child 5972: Child process is exiting
    Straight from error.log
    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

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

    Default

    So NO ONE knows?
    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. #18
    Join Date
    Nov 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Sample code showing fsockopen used with an SSL connection

    Once you have OpenSSL running within PHP, you can connect to a secure web site using port 443, and the url format of ssl://

    Below is some conceptual code, which posts two form fields (REG and TRANSACTIONTYPE) using the x-www-form-urlencoded content type, to a page called index.php on the web site securesite.com. The data returned by that index.php page is then read into a variable called $_return, and printed out to the web browser.
    Example Code

    <?php

    $http_data = 'REG=K9 DDR';
    $http_data .= '&TRANSACTIONTYPE=03';

    $fp = fsockopen("ssl://www.securesite.com",
    443, $errno, $errstr, 15);

    if (!$fp) {

    $_return = ' error: ' . $errno . ' ' . $errstr;
    die $_return;

    } else {

    $http = "POST /index.php HTTP/1.1\r\n";
    $http .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
    $http .= "User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . "\r\n";
    $http .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $http .= "Content-length: " . strlen($http_data) . "\r\n";
    $http .= "Connection: close\r\n\r\n";
    $http .= $http_data . "\r\n\r\n";

    fwrite($fp, $http);

    while (!feof($fp)) {
    $_return .= fgets($fp, 4096);
    }
    fclose($fp);

    echo $_return;
    }
    ?>

    __________________________
    RapidSSL Certificate
    Thawte SSL Certificate
    Last edited by seo4ssl; 11-05-2009 at 08:04 AM.

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
  •