fsockopen SSL warning

Posted on 2006-04-06
Last Modified: 2008-02-01
$handle = fsockopen("ssl://", 443, $errno, $errstr, 30);
   fwrite($handle, $header);
   while (!feof($handle)) {
        $data .= fgets($handle, 128);
echo $data;

When I run it I get my data plus this:

Warning: fgets() [function.fgets]: SSL: fatal protocol error in V:\Web Server\xampp\htdocs\things\ava.php on line 60
Question by:mnb93
    LVL 5

    Author Comment

    Well if I do this:

      $data .= @fgets($handle, 128);

    It suppresses it, however I would like to know what is causing it and how to stop it.
    LVL 4

    Expert Comment

    please do an echo $errno, $errstr and give it here so we can help you out.

    putting an @ in front of a function will by default suppress its error messages.
    however, they are still there; are you getting anything in your $data array ?
    LVL 5

    Author Comment

    I get data in my array;

    $errno: 0
    $errstr: (nothing)

    Also I only get the warning if I don't supress it, I belive that it is probably a bug in PHP?
    LVL 4

    Expert Comment

    i did some research on this problem and it seems to be either your or the receiving webserver its SSL isn't property configured.

    if all your data is available to you and there is nothing in $errno and/or $errstr, then you are probably good for now.
    you might wanna give a heads-up to your or the receiving webservers' server administrator to tell them that they should check their SSL settings.

    in the meantime, you could and should indeed suppress the error with the @ and not care anymore.
    LVL 5

    Author Comment

    Could I have some links to your research, please?
    (By I am not using IIS... good old Apache!)
    LVL 1

    Accepted Solution

    In my experience, I also encountered this problem when I'm building my own web server (with apache too). This is definitely not an error, as you find it out by yourself ($errno = 0). I have checked details of php.ini, but nothing can help except suppressing ALL warnings:

    error_reporting  =  E_ALL & ~E_WARNING & ~E_NOTICE & ...

    Sacrificing other warnings, I think that it is not a proper way to do so.

    The source of the problem should come from the source code, yet I am not an expert on debugging. I think the only solution is to compile it again yourself, with the "debugged" version of course. The information here maybe useful for you:

    If you think this is too troublesome, I would suggest you to suppress the message by @. This maybe the best way around.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now