linux下搭建本地HTTPS测试环境

https

有的时候我们进行开发调试时需要用到https,那么我们本地怎么搭建https呢?

输入openssl genrsa -out privkey.pem 1024/2038

[root@MiWiFi-R3P-srv ~]# openssl genrsa -out privkey.pem 1024/2038
Generating RSA private key, 1024 bit long modulus
.......++++++
.......................................++++++
e is 65537 (0x10001)

[root@MiWiFi-R3P-srv ~]# ls
anaconda-ks.cfg  blog  install.sh  privkey.pem  yumRepo_select.sh

生成了privkey.pem

2. 使用密钥privkey.pem生成证书server.pem:

openssl req -new -x509 -key privkey.pem -out server.pem -days 365

[root@MiWiFi-R3P-srv ~]# openssl req -new -x509 -key privkey.pem -out server.pem -days 365
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:zhejiang
Locality Name (eg, city) [Default City]:hangzhou
Organization Name (eg, company) [Default Company Ltd]:jinhounongye
Organizational Unit Name (eg, section) []:technology
Common Name (eg, your name or your server's hostname) []:test.com
Email Address []:2323178881@qq.com
[root@MiWiFi-R3P-srv ~]# ls
anaconda-ks.cfg blog install.sh privkey.pem server.pem yumRepo_select.sh

生成了server.pem

配置nginx证书,重启服务器

就可以以https的方式访问了

 

 


      
如果发现下载不了或者地址失效,请联系客服QQ: 2323178881
找资料 » linux下搭建本地HTTPS测试环境

提供最优质的资源集合

立即查看 了解详情