I'm trying to run a react app created with create-react-app template in HTTPS mode:
set SSL_CRT_FILE=.cert/server.pfx&&set HTTPS=true&&npm start
I created this certificate using Power Shell. Although there are lot's of explanations how to run react app with certificate created using OpenSSL, it's not an option for me as I'm not allowed to install OpenSSL on my machine.
Cert creation:
$cert = New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -DnsName "localhost" -FriendlyName "MyCert" -NotAfter (Get-Date).AddYears(10)
$pwd = ConvertTo-SecureString -String `my_password' -Force -AsPlainText
Export-PfxCertificate -Cert $cert -FilePath C:\my_react_app\.cert\server.pfx -Password $pwd
Then I imported this certificate to Personal certificates and copied it to Trusted Root Certification Authorities. But when I open the project in browser I'm getting NET::ERR_CERT_AUTHORITY_INVALID
What I'm doing wrong?
p.s.
Exporting as a .cer file also doesn't work:
Export-Certificate -Cert $cert -FilePath C:\my_react_app\.cert\server.cer
The following commands in PowerShell (run as admin) will create a root certificate and its associated trusted certificate:
1. We create a new root trusted cert:
2. We create the cert from the root trusted cert chain:
3. We copy the thumbprint returned by the last command
4. (If neccesary) We remove the last association ip/port/cert:
5. We associate the new certificate with any ip and your port, 3002 for example (the appid value does not matter, is any valid guid):
6. Now, you must drag and drop the
TestRootCA
from thePersonal/Certificates
folder toTrusted Root Certification Authorities/Certificates
.These commands also resolve the error ERR_CERT_WEAK_SIGNATURE_ALGORITHM returned later by Google Chrome because the certificate is created with SHA256 instead of SHA1