SSL Issues while Testing on LAN Dev Environment in MERN

Viewed 17

Background

I have a Express and Node API Server and a React App on my Windows Machine where I develop it. I generated a local SSL Certificate via mkcert on my local WAN IP 192.168.0.140. The local ports for both the API (5000) and React App (3000) is Port Forwarded So I can use my LAN Devices for Testing both the React APP and the API Devices. Everything Run's fine on my Local Windows Machine and I have also enabled HTTPS=true on React (also defining mkcert generated certificate in .env). This is also configured for Express API where I use https.createServer with the options: {} pointing to the same generated mkcert certificate's.


Problem

There are two problems that occur here.

  • Since mkcert doesn't generate fullchain certificate. The LAN Device's cannot verify the certificate and warn for potentially harzadous website ahead. The https:// padlock is always red on every LAN Device except for my Windows Machine.
  • The Node API Server (5000) works fine but while writing tests using Mocha and Chai for my Node API. I encounter the following error:
Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (node:_tls_wrap:1535:34)
    at TLSSocket.emit (node:events:513:28)
    at TLSSocket.emit (node:domain:489:12)
    at TLSSocket._finishInit (node:_tls_wrap:949:8)
    at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:730:12) {
  code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
  response: undefined
}

Note: The above mentioned error doesn't happen if I directly run my server via npm start. This only occurs with npm test.


My View

I know the second issue is because of mkcert not being able to generate fullchain certs. I am using my Local WAN IP: 192.168.0.140 as the address to run both React App and Node API running on different ports as explained above in "Background". How should I go about fixing the above issues. I've tried some methods such as openssl while researching on this issue but they seem to do the same thing which mkcert does.

0 Answers
Related