PhantomJS failing to open HTTPS site

后端 未结 12 1783
梦如初夏
梦如初夏 2020-11-22 07:53

I\'m using the following code based on loadspeed.js example to open up a https:// site which requires http server authentication as well.

var page = require(         


        
相关标签:
12条回答
  • 2020-11-22 08:04

    None of the other answers here helped me; it may be that the specific site(s) I was working with were too picky with their HTTP headers. This is what worked:

    var page = webpage.create();
    page.customHeaders = {
        "Connection": "keep-alive"
    };
    

    I found out that PhantomJS was using "Keep-Alive" (capitalized), and the connection was not being kept alive. :)

    0 讨论(0)
  • 2020-11-22 08:06

    What about shebang?

    If you're using shebang to execute phantomjs scripts, use the following shebang line

    #!/usr/bin/phantomjs --ignore-ssl-errors=yes
        
    var system = require('system');
    var webpage = require('webpage');
    
    // ... rest of your script
    

    Use any of the above answers. i personally like --ignore-ssl-errors=yes since it's irrelevant to validate my loopback web servers' self-signed certificate.

    0 讨论(0)
  • 2020-11-22 08:12

    Note that as of 2014-10-16, PhantomJS defaults to using SSLv3 to open HTTPS connections. With the POODLE vulnerability recently announced, many servers are disabling SSLv3 support.

    To get around that, you should be able to run PhantomJS with:

    phantomjs --ssl-protocol=tlsv1
    

    Hopefully, PhantomJS will be updated soon to make TLSv1 the default instead of SSLv3.

    0 讨论(0)
  • 2020-11-22 08:16

    The problem is most likely due to SSL certificate errors. If you start phantomjs with the --ignore-ssl-errors=yes option, it should proceed to load the page as it would if there were no SSL errors:

    phantomjs --ignore-ssl-errors=yes [phantomOptions] script.js [scriptOptions]
    

    I've seen a few websites having problems with incorrectly implementing their SSL certificates or they've expired, etc. A complete list of command line options for phantomjs is available here: http://phantomjs.org/api/command-line.html. I hope this helps.

    0 讨论(0)
  • 2020-11-22 08:18

    I was getting SSL Handshake Failed yesterday. I tried many combinations of phantomJS options (--ignore-ssl-errors=yes etc.), but none of them worked.

    Upgrading to phantomJS 2.1.1 fixed it.

    I used the phantomJS installation instructions at https://gist.github.com/julionc/7476620, changing the phantomJS version to 2.1.1.

    0 讨论(0)
  • 2020-11-22 08:19

    I tried Fred's and Cameron Tinker's answers, but only --ssl-protocol=any option seem to help me:

    phantomjs --ssl-protocol=any test.js
    

    Also I think it should be way safer to use --ssl-protocol=any as you still are using encryption, but --ignore-ssl-errors=true will ignore (duh) all ssl errors, including malicious ones.

    0 讨论(0)
提交回复
热议问题