Curl and SSL headaches

Discussion in 'PHP' started by Eager2Seo, Dec 3, 2010.

  1. #1
    I'm having major CURL and Secure SL issues. I have this working in .net, but want it on the apache server side too. The problem is I'm getting NOTHING from SSL sites. I've looked up all the possible solutions.

    I have a latest and greatest cacert.pem - nothing
    curl_setopt($ch, CURLOPT_CAINFO, "C:\xampp\htdocs\ad\cacert.pem");

    Also,
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    Tried that, I get back encrypted garbage believe it or not.

    The only way it works is thru Fiddler proxy! And I know that program fakes the certificates. I tried it on another machine and still have the issue. BTW, this is XAMPP, and this is where it has to work.

    BTW, this issue is with ANY ssl site, nothing specific.
     
    Eager2Seo, Dec 3, 2010 IP
  2. Eager2Seo

    Eager2Seo Member

    Messages:
    72
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #2
    Fixed, Just in case someone has this issue in the future, the headers I was sending were causing issue. I was loading many pages before and I try to match a browser so I don't raise eyebrows. One of the headers from a non ssl page carried over. Do not use "Accept-Encoding: gzip,deflate" with SSL.
     
    Eager2Seo, Dec 3, 2010 IP
  3. daizisheng

    daizisheng Guest

    Messages:
    122
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    78
    #3
    Why "Accept-Encoding: gzip,deflate" is not good for SSL? A bug of CURL?
     
    daizisheng, Dec 4, 2010 IP
  4. Eager2Seo

    Eager2Seo Member

    Messages:
    72
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #4
    I honestly don't know why, but after commenting out that line it worked fine. I also had to set :
    
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    Code (markup):
    To make it work.

    Offensive Header
    curl_setopt($ch,CURLOPT_HTTPHEADER,array (
                                            "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
                                           "Accept-Language: en-us,en;q=0.5",
                                //            "Accept-Encoding: gzip,deflate",
                                            "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7",
                                            "Keep-Alive: 115",
                                           "Connection: keep-alive"));
    Code (markup):
    On a side note, I did the same complex job in php and dot net. (windows forms)
    PHP/Curl handles cookies and redirects very nicely though, I can't say the same for .net. I had to do all the redirects and cookie parsing manually. PHP is easier to work with. With a Jquery UI it looks and functions much better than .net, and is portable too.

    I also switched to netbeans editor and it is much better than npp!
     
    Eager2Seo, Dec 4, 2010 IP
  5. Eager2Seo

    Eager2Seo Member

    Messages:
    72
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #5
    It is not a CURL issue. I reproduced it in .net. I think it has something to do with fiddler and SSL.
    While Fiddler was running, gzip header was working. When I close fiddler, the .net app crapped out (returned garbage). Took out GZIP and there she goes... I'm going to post to the fiddler board and see what they say....
     
    Eager2Seo, Dec 5, 2010 IP
  6. daizisheng

    daizisheng Guest

    Messages:
    122
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    78
    #6
    Thanks for such much details. I used curl in PHP and my own .NET LWP like crawler quite a lot in my daily jobs and I will definitely meet same problems in future.
     
    daizisheng, Dec 5, 2010 IP