3

I want to parse a HTTPS webpage, but it's blank when I do it. So I think it has something to do with the SSL certificate. How can I ignore this?

I'm using php-phantomjs.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
maxdachs
  • 59
  • 7
  • Duplicate of [PhantomJS failing to open HTTPS site](http://stackoverflow.com/questions/12021578/phantomjs-failing-to-open-https-site) – Artjom B. Oct 25 '15 at 20:59
  • I already saw this, but Im using the PHP version of the PhantomJS library. – maxdachs Oct 25 '15 at 21:02
  • https://github.com/jonnnnyw/php-phantomjs I found out, that i can set my config with "$client->addOption('--config=config.json');" and created the json file with the option "sslprotocol": "any", but the page is still blank – maxdachs Oct 25 '15 at 21:12
  • 1
    Nice, with $client->addOption('--ssl-protocol=any'); its working now. Thank you very much :) – maxdachs Oct 25 '15 at 21:16
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/93311/discussion-between-maxdachs-and-artjom-b). – maxdachs Oct 25 '15 at 21:20

1 Answers1

10

As seen in the question PhantomJS failing to open HTTPS site, you may need to add the following commandline options to fix SSL/TLS problems:

phantomjs --ssl-protocol=any --ignore-ssl-errors=true --web-security=false script.js

The usage in php-phantomjs is a little different, but you can use either:

$client = Client::getInstance();
$client->getEngine()->addOption('--ssl-protocol=any');
$client->getEngine()->addOption('--ignore-ssl-errors=true');
$client->getEngine()->addOption('--web-security=false');

or load a config.json file like that:

$client->getEngine()->addOption('--config=/path/to/config.json');

config.json:

{
    "sslProtocol": "any",
    "ignoreSslErrors": true,
    "webSecurityEnabled": false
}

In an older version of php-phantomjs it was necessary to use $client->addOption(...) instead of $client->getEngine()->addOption(...).

Community
  • 1
  • 1
Artjom B.
  • 61,146
  • 24
  • 125
  • 222
  • 2
    Don't use all 3 options immediately. Try to use only some of them and if it still doesn't work, use more/others. – Artjom B. Oct 25 '15 at 22:01