How to parse sites via https? I'm trying to connect to the elastix-asterisk web interface. I use the code:
$curl = curl_init(); curl_setopt($curl, CURLOPT_FAILONERROR, 1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // allow redirects curl_setopt($curl, CURLOPT_TIMEOUT, 10); // times out after 4s curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // return into a variable curl_setopt($curl, CURLOPT_URL, "https://192.168.0.18/"); curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 GTB6"); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $data = curl_exec($curl); print_r($data);
And some of the sites are parsits such as Yandex, tweeter and habr. And here an error occurs:
Warning: file_get_contents (): SSL operation failed with code 1. OpenSSL Error messages: error: 14090086: SSL routines: ssl3_get_server_certificate: certificate: C: \ OpenServer \ domains \ parser.loc \ simple_html_dom.php on line 75
Warning: file_get_contents (): Failed to enable crypto in C: \ OpenServer \ domains \ parser.loc \ simple_html_dom.php on line 75
Warning: file_get_contents ( https://192.168.0.18/ ): C: \ OpenServer \ domains \ parser.loc \ simple_html_dom.php on line 75
In firefox, writes when connecting:
192.168.0.18 uses an invalid security certificate. There is no trust in the certificate, as it is self-signed. The certificate is valid only for localhost.localdomain Error code: SEC_ERROR_UNKNOWN_ISSUER
Then I took the certificate and added it to the rest, but again an error appears:
Warning: file_get_contents (): Peer certificate CN =
localhost.localdomain' did not match expected CN=
192.168.0.18' in C: \ OpenServer \ domains \ parser.loc \ simple_html_dom.php on line 75Warning: file_get_contents (): Failed to enable crypto in C: \ OpenServer \ domains \ parser.loc \ simple_html_dom.php on line 75
Warning: file_get_contents ( https://192.168.0.18/ ): C: \ OpenServer \ domains \ parser.loc \ simple_html_dom.php on line 75
That is, a certificate is issued for localhost.localdomainn . What to do next? With elasticix it turned out, but with another site it does not go out when entering the site:
how to parse such sites?