Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical and self-signed certificates #171

Closed
khalwat opened this issue Nov 4, 2016 · 6 comments
Closed

Critical and self-signed certificates #171

khalwat opened this issue Nov 4, 2016 · 6 comments
Assignees

Comments

@khalwat
Copy link

khalwat commented Nov 4, 2016

First, many thanks for critical -- I've been using it for years, and love it.

I've run into an issue recently where I have SSL enabled on local dev, which is also where I build the critical css using gulp and critical. It took me a bit to figure out what was going on, because I'd run critical and no output at all would appear (no errors, no critical css written out).

It turns out that because the https certificate is self-signed, it's failing to render the page in PhantomJS. I google'd a bit, and found that something such as this needs to be added:

 'phantomjs.cli.args': ['--ignore-ssl-errors=true',  '--web-security=false']

But is there a way to pass this down to phantomjs via critical?

@khalwat
Copy link
Author

khalwat commented Nov 4, 2016

I found this in penthouse/lib/index.js:

// for phantomjs
var configString = '--config=' + path.join(__dirname, 'phantomjs', 'config.json')

But putting this config.json file in penthouse/lib/phantomjs didn't seem to work:

{
  "ignoreSslErrors": true,
  "webSecurity": false
}

Reference: admc/wd#358

@gmhenderson
Copy link

Here's the error I'm seeing (not sure if it's the same as you):

[10:30:31] Error: self signed certificate
    at Error (native)
    at TLSSocket.<anonymous> (_tls_wrap.js:1060:38)
    at emitNone (events.js:86:13)
    at TLSSocket.emit (events.js:185:7)
    at TLSSocket._finishInit (_tls_wrap.js:584:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:416:38)

This is actually an error from request. A quick and dirty hack is to replace line 85 of file-helper.js with:

request({url: uri, strictSSL: false}, function (err, resp) {

The strictSSL option needs to be set to false.

@khalwat
Copy link
Author

khalwat commented Nov 9, 2016

I didn't see any errors output at all. What I did for a temporary fix is to allow the website to run both http and https in local dev.

I'd ideally like to be able to pass params down to Penthouse/PhantomJS via Critical. I can see it being useful for this, as well as other issues.

@spAnser
Copy link

spAnser commented Oct 3, 2017

I managed to fix this by putting this at the top of my javascript.

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"

@bezoerb bezoerb self-assigned this Oct 6, 2017
@bezoerb
Copy link
Collaborator

bezoerb commented Oct 6, 2017

Thanks for reporting and sorry for the late response. We'll adding a fix for this in the next release.

@bezoerb
Copy link
Collaborator

bezoerb commented Nov 6, 2017

v1.0.0 Released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants