CasperJS/PhantomJS failing SSL handshakes on some sites even with --ssl-protocol=any

旧街凉风 提交于 2019-12-22 08:13:07

问题


I've had issues with CasperJS and SSL, but using --ssl-protocol=any has always fixed the problem, as referenced in this answer. In this case, I'm still having issues.

I put this in the command line:

casperjs --ssl-protocol=any --ignore-ssl-errors=true sanity.js

This is sanity.js:

 var casper = require('casper').create({
    verbose: true,
    logLevel: 'debug'
});

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);
});

casper.start('https://www.google.com/', function() {
    this.echo(this.getTitle());
});

casper.thenOpen('https://www.zazzle.com/lgn/signin', function() {
    this.echo(this.getTitle());
});

casper.run();

The first URL loads fine. But then the SSL handshake fails in the second one. Debug output:

[info] [phantom] Starting...
[info] [phantom] Running suite: 4 steps
[debug] [phantom] opening url: https://www.google.com/, HTTP GET
[debug] [phantom] Navigation requested: url=https://www.google.com/, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "https://www.google.com/"
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/4 https://www.google.com/ (HTTP 200)
Google
[info] [phantom] Step anonymous 2/4: done in 876ms.
[debug] [phantom] opening url: https://www.zazzle.com/lgn/signin, HTTP GET
[debug] [phantom] Navigation requested: url=https://www.zazzle.com/lgn/signin, type=Other, willNavigate=true, isMainFrame=true
Unable to load resource (#9URL:https://www.zazzle.com/lgn/signin)
Error code: 6. Description: SSL handshake failed
[warning] [phantom] Loading resource failed with status=fail: https://www.zazzle.com/lgn/signin
[info] [phantom] Step anonymous 4/4 https://www.google.com/ (HTTP 0)
Google
[info] [phantom] Step anonymous 4/4: done in 1178ms.
[info] [phantom] Done 4 steps in 1197ms

I'm running PhantomJS version 1.9.7 and CasperJS version 1.1.0-beta3. I'm a bit clueless when it comes to the finer points of SSL, but I'm having trouble finding any more ways to fix this. Any help would be awesome!

来源:https://stackoverflow.com/questions/29441151/casperjs-phantomjs-failing-ssl-handshakes-on-some-sites-even-with-ssl-protocol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!