Jump to content
Sign in to follow this  
墨香年少

react自签名证书使用https

Recommended Posts

在react项目目录下,打开cmd,输入:

openssl req -x509 -newkey rsa:2048 -keyout keytmp.pem -out cert.pem -days 365

1.png

 

第二步,输入:

openssl rsa -in keytmp.pem -out key.pem

打开:package.json

修改:

"start": "export HTTPS=true&&SSL_CRT_FILE=cert.pem&&SSL_KEY_FILE=key.pem react-scripts start",

然后cmd输入:set HTTPS=true&&yarn start 启动react

,chrome会提示证书无效,在chrome中导入证书到信任区域后,重新打开chrome,重新打开https://localhost:3000

此时证书正常!


目之所及,皆是回忆,心之所想,皆是过往

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

注册必须使用2-8个中文汉字作为账号