When attempting to load an HTTPS page using PhantomJS/CasperJS, you may encounter an error despite setting "ignore-ssl-errors" and modifying user agents.
This issue could stem from the SSLv3 vulnerability (POODLE), prompting website owners to disable SSLv3 support. Since earlier versions of PhantomJS default to SSLv3, switching to TLSv1 or even "any" SSL protocol resolves the problem:
casperjs --ssl-protocol=tlsv1 yourScript.js
casperjs --ssl-protocol=any yourScript.js
Alternatively, updating to PhantomJS 1.9.8 or later addresses the issue, although it introduces a separate bug.
To verify if SSLv3 is the cause, implement a "resource.error" event handler:
casper.on("resource.error", function(resourceError){ console.log('Unable to load resource (#' + resourceError.id + 'URL:' + resourceError.url + ')'); console.log('Error code: ' + resourceError.errorCode + '. Description: ' + resourceError.errorString); });
If the error matches "Error code: 6. Description: SSL handshake failed," SSLv3 is likely the culprit.
Lastly, consider using the "--ignore-ssl-errors=true" command-line option to handle certificate issues.
The above is the detailed content of Why is PhantomJS Failing to Load HTTPS Pages Despite \'ignore-ssl-errors\' and User Agent Changes?. For more information, please follow other related articles on the PHP Chinese website!