Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

How to avoid "self signed certificate" error? #229

Closed
k1tzu opened this issue Nov 10, 2017 · 12 comments
Closed

How to avoid "self signed certificate" error? #229

k1tzu opened this issue Nov 10, 2017 · 12 comments

Comments

@k1tzu
Copy link

k1tzu commented Nov 10, 2017

import fetch from 'isomorphic-fetch';

const httpLink = new HttpLink({
  fetch,
  uri: `https://localhost:3000/graphql`,
});
@rtymchyk
Copy link

This used to be fix-able with agent: new https.Agent({ rejectUnauthorized: false }), given to a network interface. Now I don't know.

@k1tzu
Copy link
Author

k1tzu commented Nov 29, 2017

process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; did the thing for me.

@k1tzu k1tzu closed this as completed Nov 29, 2017
@rtymchyk
Copy link

For anyone wondering, you can also do:

const link = createHttpLink({
    fetchOptions: {
      agent: new https.Agent({ rejectUnauthorized: false }),
    },
})

@jbaxleyiii
Copy link
Contributor

@rtymchyk would you be able to add this to the docs? And what use case does this solve? I'm not familiar with agent?

@rtymchyk
Copy link

@jbaxleyiii The use case it solves for me is connecting to my API node that has a self-signed SSL certificate on the dev environment. Requests from Apollo do not complete otherwise. I can add to docs if you think it's common enough.

@jbaxleyiii
Copy link
Contributor

I'm not sure its common enough but I could imagine people getting stuck on it and hard to find. I'd love to see it as a recipe if you are open to it!

@zhaiduo
Copy link

zhaiduo commented Mar 21, 2018

@rtymchyk https module seems works only in NodeJs, How could it work in RN client?

When I try this on Android device (iOS device no problem), get the following error:

Error: While trying to resolve module https from file .../node_modules/https-agent/index.js, the package .../node_modules/https/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (.../node_modules/https/index.js. Indeed, none of these files exist:

@rtymchyk
Copy link

Sorry, I'm not familiar with RN and what's available there.

@zhaiduo
Copy link

zhaiduo commented Mar 22, 2018

It's Android 7.0's bug. facebook/react-native#17891

@dani-z
Copy link

dani-z commented Apr 12, 2018

With React Native you can't use https node module. Just speaking for myself the use case would be to test https connection in a react RN App locally, because iOS does not support anymore unsecured API calls.

@pedzed
Copy link

pedzed commented Nov 10, 2019

process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; did the thing for me.

Where did you put it?

@dsolivera
Copy link

dsolivera commented Apr 20, 2020

process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; did the thing for me.

Where did you put it?

@pedzed add process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; in your you index.js file right after all the LaunchAPI & UserAPI constants. That should solve the problem.

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

No branches or pull requests

7 participants