Home  >  Article  >  Backend Development  >  Curl requests the https URL, which causes the connection to be reset after I open the web page.

Curl requests the https URL, which causes the connection to be reset after I open the web page.

WBOY
WBOYOriginal
2016-10-10 11:56:033308browse

Today, I deployed an older program on Alibaba Cloud, using Alibaba Cloud's esc. The environment is as follows:

  • PHP Version 5.2.17

  • Apache/2.2.29 (Unix)

  • Mysql 5.1.73

The index.php file contains the following code

<code>$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'http://www.baidu.com/');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$info = curl_exec($ch);
curl_close($ch);
echo $info;</code>

When I visit domain name/index.php, the Baidu page appears normally.
But after I made some modifications, the connection was reset and the connection was reset. I searched online and found no effective solution.

<code>$ch = curl_init();

curl_setopt($ch,CURLOPT_URL,'https://www.baidu.com/');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$info = curl_exec($ch);
curl_close($ch);
echo $info;</code>

Curl requests the https URL, which causes the connection to be reset after I open the web page.

What causes this problem? Is it a php version problem or some other reason? Thank you for your help!

Reply content:

Today, I deployed an older program on Alibaba Cloud, using Alibaba Cloud's esc. The environment is as follows:

  • PHP Version 5.2.17

  • Apache/2.2.29 (Unix)

  • Mysql 5.1.73

The index.php file contains the following code

<code>$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'http://www.baidu.com/');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$info = curl_exec($ch);
curl_close($ch);
echo $info;</code>

When I visit domain name/index.php, the Baidu page appears normally.
But after I made some modifications, the connection was reset. I searched online and found no effective solution.

<code>$ch = curl_init();

curl_setopt($ch,CURLOPT_URL,'https://www.baidu.com/');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$info = curl_exec($ch);
curl_close($ch);
echo $info;</code>

Curl requests the https URL, which causes the connection to be reset after I open the web page.

What causes this problem? Is it a php version problem or some other reason? Thank you for your help!

What era is it, still using 5.2. . . . . . . .

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn