cujojs / rest

RESTful HTTP client for JavaScript
http://cujojs.com/
Other
1k stars 146 forks source link

HTTPS self-signed certificate ignore option needed #159

Closed Rulevoid closed 7 years ago

Rulevoid commented 7 years ago

I am interacting with a local self-signed development server and receive the following error when attempting to interface with it over HTTPS: UNABLE_TO_VERIFY_LEAF_SIGNATURE

I do not see a simple option in the documentation to bypass this.

scothis commented 7 years ago

When running in node, you can add configuration properties with the mixin request property. These values will be added to the options object passed to http.request.

Rulevoid commented 7 years ago

I am using Node for testing, however, this will ultimately be used in a client web-browser. Will the solution change depending on environment in which it is running? Also, I'm not sure exactly what the solution would need to look like. Any help would be appreciated there.

scothis commented 7 years ago

Are you running with a local development server that has a self signed certificate or an otherwise invalid SSL cert?

The quick a dirty solution is to disable verification of the SSL certificate, but this is generally a very bad idea, and certainly not something that should ever be used with sensitive data.

rest({
  path: 'https://localhost/',
  mixin: {
    rejectUnauthorized: false
  }
}).then(...);

Additional SSL options can be configured here as well.

In the browser, you're at the mercy of the certificates the browser is configured to accept. As JS, you have no influence.

Rulevoid commented 7 years ago

Your assumption is correct.

This solution is working for me while testing locally. I appreciate it!