问题
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