question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ember s + fastboot + ssl + self-signed cert == :(

See original GitHub issue

Scenario: developing an ember app with SSL turned on. Using a self-signed cert for development.

Client-rendering works just fine as you can trust the cert for development. However, fastboot will use najax to make the request. With the proxy url being https najax will failed with Error: self signed certificate.

there are several potential solutions explained here: http://stackoverflow.com/questions/20433287/node-js-request-cert-has-expired/29397100#29397100

however, because najax is being run within the sandbox vm we don’t have access to process.env to use the unrecommended process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; override. Also, if we anted to add the PEM buffer to najax’s options as a new CA we don’t have access to the file system to create that buffer.

One temporary solution (for those that might hit this)

Within the development environment scope in config/environment.js we have added:

// localhost:4000 is the address of our locally running API server
ENV.fastboot.hostWhitelist.push('http://localhost:4000');
ENV.fastboot.apiHost = 'http://localhost:4000';

then we injected the FastBoot service into the application adapter and made the adapter’s host property a CP:

fastboot: inject(),
host: computed(function() {
  let host;

  if (get(this, 'fastboot.isFastBoot')) {
    host = config.fastboot.apiHost;
  }

  return host || config.apiHost;
})

Another solution is to set the rejectUnauthorized in the request options being passed to najax. You’ll have to override ajaxOptions on your adapter:

ajaxOptions() {
  let hash = this._super(...arguments);
  hash.rejectUnauthorized = false;
}

Hopefully that helps others. But I would advocate for a more permanent solution that respected how najax wants to make requests for ssl.

One potential fix for this is to set the rejectUnauthorized flag for the options passed to najax. This could be limited to the development environment only: https://nodejs.org/api/tls.html#tls_tls_connect_options_callback

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
stefanpennercommented, Jul 2, 2017

@bcardarella i’ve been thinking about this more. I think fastboot can do a better job of providing “ajax” to apps using it, and by doing so also expose first-class configuration for certs…

1reaction
kernel-iocommented, Jan 28, 2018

in development I set the NODE_TLS_REJECT_UNAUTHORIZED environment variable to 0 before starting fastboot, this seems to have the desired result while using ember-fetch

Read more comments on GitHub >

github_iconTop Results From Across the Web

ember.js - Self signed certificate in certificate chain error after ...
I am inside coorpration proxy and I have an certification error everytime I start the ember server, ➜ Dummy ember s Could not...
Read more >
ember-fastboot-deploy - npm
Node Express middleware to deploy Ember applications into a FastBoot server. Latest version: 0.1.11, last published: 7 years ago.
Read more >
Serving Ember and Rails locally with SSL/TLS | by Cory Forsyth
Because your app is running locally, a self-signed certificate will suffice. Step 1: Generate a self-signed cert. Heroku has a nice guide to ......
Read more >
Ember FastBoot
FastBoot works by running your Ember application in Node.js. When a user visits your site, the initial HTML is rendered and served to...
Read more >
Developing an Ember.js app on https - Balint Erdi
If you also use a self-signed certificate for the API you have to pass the --secure-proxy=false option. That instructs Ember CLI not to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found