Menu

#99 SSL requests return 'HTTP/1.1 400 Bad request' in PHP 7

open
nobody
None
5
2023-08-20
2018-07-11
Anonymous
No

Crawling a site with HTTPS might result in all requests to return
400 - Bad request
The reason for this seems to be a problem residing in the use of the stream_socket_client() function with the IP instead of the HOST.

Solution (for me) was to modify the PHPCrawlerHTTPRequest.class.php:

There's a block handling SSL requests:

// If ssl -> perform Server name indication
if ($this->url_parts["protocol"] == "https://"){
            $this->socket = @stream_socket_client($protocol_prefix.$ip_address.":".$this->url_parts["port"], $error_code, $error_str, $this->socketConnectTimeout, STREAM_CLIENT_CONNECT, $context);

...which is using the target's IP and not the hostname. I modified that to be :

// If ssl -> perform Server name indication
if ($this->url_parts["protocol"] == "https://"){
            $this->socket = @stream_socket_client($protocol_prefix.$this->url_parts["host"].":".$this->url_parts["port"], $error_code, $error_str, $this->socketConnectTimeout, STREAM_CLIENT_CONNECT, $context);

That got me rid of the problem and the requests are now processed properly. Ideally, in a rework of the class, there could be a flag to switch between HOST or IP.

PS: The location of the codechange is about the same spot where you would apply Ahmed's patch for the peer verification (https://sourceforge.net/p/phpcrawl/bugs/86/) which might also cause essential problems from PHP5.6.

Hope that helps. Feedback is welcome.

Discussion

  • Anonymous

    Anonymous - 2022-07-17
    Post awaiting moderation.
    • Anonymous

      Anonymous - 2022-07-17
      Post awaiting moderation.
    • Anonymous

      Anonymous - 2022-10-28
      Post awaiting moderation.
    • Anonymous

      Anonymous - 2022-11-30
      Post awaiting moderation.
    • Anonymous

      Anonymous - 2023-03-02

      ในเวลานี้ เชื่อว่าคนไทยนั้นต้องเผชิญกับปัญหาตกงานหรือมีปัญหาเรื่องของการเงินอย่างแน่แท้ เพราะว่าไม่ว่าจะเป็นเศรษฐกิจที่เสื่อมถอย ไม่สามารถปฏิบัติงานหารายได้
      วันนี้ทางเว็บตรงไม่ผ่านเอเย่นต์เปิดใหม่มีวิธีการหาเงินง่ายๆกับการเล่นเกมสล็อตเว็บตรงที่เป็นเกมออนไลน์หาเงินได้จริง สามารถหาเงินออนไลน์ได้ทุกที่ทั้งวัน 24 ชั่วโมง ซึ่ง g2gbk8 เป็นสล็อต เว็บตรงไม่ผ่านเอเย่นต์ไม่มีขั้นต่ำมีมั่นคงถูกต้องตามกฎหมายคาสิโนสากล ประกันจากผู้เล่นจริงทั่วทั้งประเทศ เพื่อนๆสามารถหาเงินกล้วยๆ โดยทาง g2gbk8
      นั้นมีค่ายเกมjoker roma เว็บตรง,pgslot
      เว็บตรงวอเลท,slotxo เว็บตรงไม่ผ่านเอเย่นต์,สล็อตซุปเปอร์ เพียงแค่สมัครเว็บตรง pgกับทาง g2gbk8 ที่เป็นเว็บเกมสล็อต ซึ่งไม่ผ่านตัวแทนหรือตัวกลางใดๆก็ตามเล่นslotonlineได้โดยตรงกับค่ายเกม มีเกมslotonlineให้เลือกเล่นมากกว่า
      500 เกม แล้วก็ยังมีบริการต่างๆเยอะมากที่จะเพิ่มความสะดวกสบายให้กับสมาชิกสล็อตเว็บตรงไม่ผ่านเอเย่นต์ ไม่ว่าจะเป็นการฝาก-ถอน ไม่มีอย่างต่ำแล้วก็มีความรวดเร็วประมวลผลด้วยระบบออโต้ มีความเที่ยงตรงสูง ไม่จำเป็นต้องส่งสลิปการโอนให้กับทางแอดมินให้เสียเวล่ำเวลา หรือจะเป็นโปรโมชั่นแจกฟรีเครดิต100%
      หรือจะเป็นโปรฝาก 9 รับ 100 เพื่อนๆสามารถหาเงินออนไลน์ได้แล้วที่เว็บตรงสล็อต G2GBET

       
    • Anonymous

      Anonymous - 2023-04-02
      Post awaiting moderation.
    • Anonymous

      Anonymous - 2023-04-09
      Post awaiting moderation.
    • Anonymous

      Anonymous - 2023-05-05
      Post awaiting moderation.
    • Anonymous

      Anonymous - 2023-05-16
      Post awaiting moderation.
    • Anonymous

      Anonymous - 2023-07-12
      Post awaiting moderation.
    • Anonymous

      Anonymous - 2023-08-16
      Post awaiting moderation.
    • Anonymous

      Anonymous - 2023-08-20
      Post awaiting moderation.

Anonymous
Anonymous

Add attachments
Cancel