I. Description
file_get_contents() error when reading https content
II. Reason
Local service is not configured ssl certificate, can not get the contents of the path to https
III. Solution
1, Linux server configuration https ssl certificate.
Linux server configuration https ssl certificate.
2. curl_ request to obtain the content (see the following method curlGet ())
/**
* get the content
* @param $url
* @return bool|string
*/
function curlGet($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36');
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$content = curl_exec($ch);
curl_close($ch);
return ($content);
}
3.Use file_get_contents() function to skip https authentication
$streamOpts = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false
]
];
$html = file_get_contents($pageUrl, false, stream_context_create($streamOpts));
Read More:
- [Solved] file_get_contents(): SSL operation failed with code 1
- PHP curl error: SSL certificate problem: unable to get local issuer certificate settlement program
- Mac installs the php Swoole extension and appears Enable openssl support, require openssl library or fatal error:’openssl/ssl.h’ file not found
- composer Error: The requested PHP extension ext-bcmath * is missing from your system. Install or enable
- Error during session start; please check your PHP and/or webserver log file and configure your PHP
- PHP: How to parse MHT file into HTML
- PHP: How to get the total number of data in the MySQL table (total number of rows)
- PHP file download, download failed, nginx open() nginx / fastcgi_ temp/2/10/0000000102“ failed (13: Permission denied)
- [PHP] php8 jit does not support 32-bit systems WARNING: JIT not supported by host architecture
- php Error: mail() Failed to connect to mailserver at “localhost” port 25
- [Solved] PHP getimagesize(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL
- /www/server/php/56/sbin/php-fpm:error while loading shared libraries:libssl.so.1.0. 0:cannot open shared object file:No such file or directory
- php_network_getaddresses: getaddrinfo failed (How to Fix)
- [Solved] Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path:
- PHP large file upload error 413: request entity too large [How to Solve]
- Tp6 Cannot enable error [How to Solve]
- [Solved] cURL error 60: SSL certificate problem: unable to get local issuer certificate
- PHP Error Object of class mysqli could not be converted to string in
- How to Hide index.php
- PHP encryption 3DES error Call to undefined function: mcrypt_module_open() solution