php5openssl

Discussion in 'General' started by bernholdt, Sep 8, 2008.

  1. bernholdt

    bernholdt Member

    Hi im sitting and struggeling with a payment script in Joomla/Virtuemart
    but im kinda stuck :confused:
    In my info php i have info.php Registered Stream Socket: Transports tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
    But as far as i have read i need: Registered PHP Streams php, file, http, ftp, compress.bzip2, https, ftps, compress.zlib, ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp

    I hope this make sence to anyone here :)
     
  2. jnsc

    jnsc rotaredoM Moderator

    In http://ch2.php.net/manual/en/function.fsockopen.php It's written :

    So do not use https:// but ssl://
     
  3. bernholdt

    bernholdt Member

  4. marcellosales

    marcellosales New Member

    Same problem here... PHP 5.2.6

    I've tried everything as well... Here are some info from my phpinfo.

    Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, sslv2, tls

    Apache Version Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch mod_ssl/2.2.8 OpenSSL/0.9.8g

    OpenSSL support enabled
    OpenSSL Version OpenSSL 0.9.8g 19 Oct 2007

    Please, let me know... I'm getting the same error while trying to make an HTTP POST request to a secure website...

    =============================================================
    $sock = fsockopen("https://www.dev.java.net/servlets/TLogin", 80, $errno, $errstr, 30);
    if (!$sock) die("$errstr ($errno)\n");

    $data = "loginID=" . urlencode("xyz") . "&password=" . urlencode("abc")
    . "&detour=" . urlencode("https://myproject.dev.java.net/servlets/ProjectMailingListList");

    fwrite($sock, "POST /form_action.php HTTP/1.0\r\n");
    fwrite($sock, "Host: www.dev.java.net\r\n");
    fwrite($sock, "Content-type: application/x-www-form-urlencoded\r\n");
    fwrite($sock, "Content-length: " . strlen($data) . "\r\n");
    fwrite($sock, "Accept: */*\r\n");
    fwrite($sock, "\r\n");
    fwrite($sock, "$data\r\n");
    fwrite($sock, "\r\n");

    $headers = "";
    while ($str = trim(fgets($sock, 4096)))
    $headers .= "$str\n";

    echo "\n";

    $body = "";
    while (!feof($sock))
    $body .= fgets($sock, 4096);

    echo $body;
    fclose($sock);
    =====================================================

    The script dies in the line

    if (!$sock) die("$errstr ($errno)\n");

    and here is the error message...

    fsockopen() [function.fsockopen]: unable to connect to Unable to find the socket transport "https" - did you forget to enable it when you configured PHP?
     
  5. falko

    falko Super Moderator Howtoforge Staff

  6. marcellosales

    marcellosales New Member

    cURL is the way to go...

    Falko,

    I tried all different possibilities with ports (80, 443), protocol (ssh:// https://, without protocol) and nothing works... Java.net uses SSL (as they offer WS APIs and that's the only way to go, through tunneled 80).

    I moved to cURL and it's working fine... I can mimic the browser without any problems, using cookies, etc...Here's my working example...

    $cookie_file_path = tempnam("./","crawler-cookie");

    $LOGINURL = "https://www.dev.java.net/servlets/TLogin";
    $reffer = $LOGINURL;

    $projectName = "ppm-8";
    $fields = array(
    'detour'=>urlencode("https://".$projectName.".dev.java.net/servlets/ProjectMailingListList"),
    'loginID'=>urlencode("xxxxxx"),
    'password'=>urlencode("yyyyyyy"),
    'Login'=>urlencode("Login")
    );

    # //url-ify the data for the POST
    foreach($fields as $key=>$value) {
    $fields_string .= $key.'='.$value.'&';
    }
    $fields_string = rtrim($fields_string,'&');

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$LOGINURL);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_REFERER, $reffer);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
    $result = curl_exec ($ch);
    curl_close ($ch);
    print $result;

    Thanks
     
  7. marcellosales

    marcellosales New Member

     

Share This Page