Using self signed certificates in a React Native project

In my Expo managed React Native project, I use apisauce, a cool package that essentially just wraps around the Axios HTTP client package.

In order to get self signed certificates working, people were setting the HTTP Agent to stop verifying SSL certificates, like so:

const httpsAgent = new https.Agent({
  rejectUnauthorized: false
});

…and then pass that in to the axios config. I’m happy to say there is a better way!

  • Download and install Proxyman from here https://proxyman.io/ , load it up.
  • Send your selfsigned.crt to your iPhone via airdrop, install the profile in the Settings app.
  • In your Wifi settings, set Proxy to manual with your IP and port 9090.
  • Open Safari and browse to proxy.man/ssl, again install the profile
  • Finally, go into Settings > General > About > Certificate Trust Settings, and switch on Enable Full Trust for both the proxy man cert and your dev domain self signed cert.

Now you should be able to browse to https://your-dev-domain and Axios (apisauce) will not return any Network Errors. 😎

Leave a comment