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

https module doesn't seems to be working properly #137

Open
bsumer-wyn opened this issue Feb 12, 2024 · 4 comments
Open

https module doesn't seems to be working properly #137

bsumer-wyn opened this issue Feb 12, 2024 · 4 comments

Comments

@bsumer-wyn
Copy link

Hi, I have shimmed https and https modules, and when I try to create a new httpsAgent, it returns an empty object. I wonder what I am doing wrong. What I am trying to do is basically passing my ssl certificate and private key to the httpsAgent so I can be authenticated in the server without using a VPN client. Help would be greatly appreciated. Thanks

const httpsAgent = new https.Agent({
  cert: cert2,
  key: key2,
  rejectUnauthorized: false,
});
console.log("AGENT", httpsAgent);

This is my dependencies:


  "react-native": {
    "https": "https-browserify",
    "http": "@tradle/react-native-http"
  },
  "browser": {
    "https": "https-browserify",
    "http": "@tradle/react-native-http"
  }

My shim file:

if (typeof __dirname === 'undefined') global.__dirname = '/';
if (typeof __filename === 'undefined') global.__filename = '';
if (typeof process === 'undefined') {
  global.process = require('process');
} else {
  const bProcess = require('process');
  for (var p in bProcess) {
    if (!(p in process)) {
      process[p] = bProcess[p];
    }
  }
}

process.browser = false;
if (typeof Buffer === 'undefined') global.Buffer = require('buffer').Buffer;

// global.location = global.location || { port: 80 }
const isDev = typeof __DEV__ === 'boolean' && __DEV__;
process.env.NODE_ENV = isDev ? 'development' : 'production';
if (typeof localStorage !== 'undefined') {
  localStorage.debug = isDev ? '*' : '';
}

// If using the crypto shim, uncomment the following line to ensure
// crypto is loaded first, so it can populate global.crypto
// require('crypto')

@Braudin
Copy link

Braudin commented Feb 23, 2024

Me sumo a esta pregunta

@Shahanshah-TA
Copy link

Hi @bsumer-wyn did you find any solution for this?

@Shahanshah-TA
Copy link

Shahanshah-TA commented Jul 10, 2024

@mvayngrib
Copy link
Member

hey guys, the implementation for this comes from react-native-http, which is a tiny adaptation on top of http-browserify, which doesn't support http.Agent https://github.com/browserify/http-browserify/blob/17b2990010ebd39461d1117c1e2c50c25eab869f/index.js#L49

it's probably possible to implement in react native, unlike in the browser, but it's not something i'll be able to do personally. PRs welcome to react-native-http :)

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