Create a self-signed SSL certificate for React JS, before starting to explore, I want to add a little bit about this
A self-signed certificate is a digital certificate that is created and signed by the same entity it identifies. Unlike certificates issued by trusted Certificate Authorities (CAs), self-signed certificates aren't verified by external parties. They're commonly used for local development, testing, or internal systems where the identity verification provided by a CA is not necessary. Although self-signed certificates can secure communication, they lack the third-party validation provided by CA-signed certificates, and users may encounter browser warnings when accessing websites using self-signed certificates.
it will done in a few steps
there are lots of ways to create a Self-signed certificate but I am using here mkcert
you can visit this URL
and download the steps to install Chocolatey, if you don't want to visit it just need to follow the steps for Windows
1. Open the PowerShell in administrator mode and execute the below script
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
once you execute it, it will download the Chocolatey, and also create the environment in your window machine
to verify, you can simply check the environmental variable from your compute property
you can also verify from the install location by opening
once you verify, need to execute some other commands, in the Powershell
2. choco install mkcert
you can also ensure the mkcert is installed or not by checking the same location.
once you verify just run the
3. mkcert -version
to check which version was installed.
now the next step is to execute
4. mkcert -install
this command installed the mkcert environment on your machine
now we are in the final step, you have to open your Visual Studio Code, solution inside the root folder of your react app, and execute the below commands
5. mkcert -key-file localhost-key.pem -cert-file localhost.pem localhost
these commands create key and certificate files in your local machine, here I am using localhost for my local development environment, you can replace it if you are using any specific domain for development
now we are very close.
the last step is to open your package.json file and add the path on the start command example
These commands told the system to start in https mode.
now you only need to run this
6. npm start
Thanks for referring to the article, please tell me if it is helpful to you.