React Native localhost SSL certificate is Invalid

SDK Version: 3.18.6

I’ve started this React Native project using Expo a few weeks ago, and everything was going fine until yesterday.

When I ran expo start , I got the Metro Bundler as usual, and I click “Run in web browser”, as usual, the VS Code terminal prompted me with a password input for a localhost certificate thing. I have no idea what it was, but there was this link to some local SSL signing tool, that I also don’t know anything about. Even with the link I wasn’t sure what password I was supposed to type in, so I just pressed enter without typing anything and that’s where I’m at now.

I can’t run my app in the browser anymore. Whenever I try to do so, I get this:

PS D:\Projects\GroceryApp\GroceryApp.Web> expo start
Starting project at D:\Projects\GroceryApp\GroceryApp.Web
Expo DevTools is running at http ://localhost:19003/
Opening DevTools in the browser… (press shift-d to disable)
Ensuring auto SSL certificate is created (you might need to re-run with sudo)
Starting Metro Bundler on port 19001.
debug Watch mode is not supported in this environment
debug Checking for a newer version of React Native
debug Current version: 0.61.4
debug No release cache found
debug No release cache found
debug Checking for newer releases on GitHub
debug No release cache found
debug Saving “6d6386b01438c6ef0acd213d304b5839” to cache
debug No release cache found
debug No release cache found
debug Latest release: 0.60.0
Tunnel ready.
exp://192.168.0.108:19000

QRCODE

To run the app with live reloading, choose one of:

• Sign in as @gcorneto in Expo client on Android or iOS. Your projects will automatically appear in the “Projects” tab.

• Scan the QR code above with the Expo app (Android) or the Camera app (iOS).

• Press a for Android emulator, or w to run on web.

• Press e to send a link to your phone with email.

Expo Press ? to show a list of all available commands.

Logs for your project will appear below. Press Ctrl+C to exit.

So, I tried forcing it by pressing W , and then I get this:

Attempting to open the project in a web browser…
(node:15116) UnhandledPromiseRejectionWarning: Error: The certificate “D:\Projects\GroceryApp\GroceryApp.Web.expo\web\development\ssl\cert-localhost.pem” is invalid.
error:2007E073:BIO routines:BIO_new_mem_buf:null parameter at validateKeyAndCerts (C:\Users\Redacted\AppData\Roaming\npm\node_modules\expo-cli\node_modules@expo\webpack-config\src\addons\withDevServer.ts:26:11) at getHttpsConfig (C:\Users\Redacted\AppData\Roaming\npm\node_modules\expo-cli\node_modules@expo\webpack-config\src\addons\withDevServer.ts:62:5) at createDevServer (C:\Users\Redacted\AppData\Roaming\npm\node_modules\expo-cli\node_modules@expo\webpack-config\src\addons\withDevServer.ts:191:12) at Object.withDevServer (C:\Users\Redacted\AppData\Roaming\npm\node_modules\expo-cli\node_modules@expo\webpack-config\src\addons\withDevServer.ts:101:31) at Object. (C:\Users\Redacted\AppData\Roaming\npm\node_modules\expo-cli\node_modules@expo\webpack-config\src\webpack.config.ts:419:21) at Generator.next () at C:\Users\Redacted\AppData\Roaming\npm\node_modules\expo-cli\node_modules@expo\webpack-config\webpack\webpack.config.js:8:71
at new Promise () at __awaiter (C:\Users\Redacted\AppData\Roaming\npm\node_modules\expo-cli\node_modules@expo\webpack-config\webpack\webpack.config.js:4:12) at Object.default_1 [as default] (C:\Users\Redacted\AppData\Roaming\npm\node_modules\expo-cli\node_modules@expo\webpack-config\webpack\webpack.config.js:87:12) at C:\Users\Redacted\AppData\Roaming\npm\node_modules\expo-cli\node_modules@expo\webpack-config\src\index.ts:21:71 at Generator.next () at C:\Users\Redacted\AppData\Roaming\npm\node_modules\expo-cli\node_modules@expo\webpack-config\webpack\index.js:8:71 at new Promise () at __awaiter (C:\Users\Redacted\AppData\Roaming\npm\node_modules\expo-cli\node_modules@expo\webpack-config\webpack\index.js:4:12)
at createWebpackConfigAsync (C:\Users\Redacted\AppData\Roaming\npm\node_modules\expo-cli\node_modules@expo\webpack-config\webpack\index.js:26:12)
(node:15116) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https ://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6)
(node:15116) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Which makes sense, because that file is completely empty.
Sorry for long post, I wanted to make sure all the logs were here.

Help please. Thanks in advance.

Wait, installing an older version fixes the problem?

try starting the server with expo start --no-https - we default to starting with https enabled because a lot of web apis only work in that context, eg: camera.

1 Like

Yeah, that works. But the thing that I need is exactly https.
I know I broke it, it worked fine before. I need to fix whatever it is that I broke.

maybe try deleting the file that the error says is invalid - D:\Projects\GroceryApp\GroceryApp.Web.expo\web\development\ssl\cert-localhost.pem

I did it. It just creates the file back up.
I tried deleting both the cert-localhost.pem and the key-localhost.pem that is in the same folder. They both are generated back.

Deleted last post because --no-https was adequate for me.

Hi @notbrent

I just tried this and I think the Password prompt could really do with a better explanation if possible. I also did not know what password was being requested, until I saw the sudo: 3 incorrect password attempts error.

2 Likes

Expo just released version 3.19.2, and upgrading to it sort of fixed this for me. It still fails to create a safe local certificate, but I can now open it as an unsafe domain (chrome show me that infamous unsafe certificate screen), but at least I get to use my https local domain.

I’ll mark this as a solution simply because the original issue doesn’t happen anymore. But my local SSL certificate, that was supposed to be sign with devcert, is still broken.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.