nginx证书制作

前置条件:最好是在linux虚拟机上进行,且虚拟机有openssl命令

1.创建服务器证书密钥文件 server.key

此命令执行后会要求输入密码,确认密码,自己随便定义,但是要记住,后面会用到。

openssl genrsa -des3 -out server.key 2048

2.创建服务器证书的申请文件 server.csr

openssl req -new -key server.key -out server.csr

此命令输出内容为:

Enter pass phrase for root.key: ← 输入前面创建的密码
Country Name (2 letter code) [AU]:CN ← 国家代号,中国输入CN
State or Province Name (full name) [Some-State]:ZHEJIANG← 省的全名,拼音
Locality Name (eg, city) []:HANGZHOU← 市的全名,拼音
Organization Name (eg, company) [Internet Widgits Pty Ltd]:xxxunit ← 公司英文名
Organizational Unit Name (eg, section) []: ← 可以不输入
Common Name (eg, YOUR name) []:xxx.bg.com← 输入域名,如:iot.conet.com
Email Address []:xxx@bg.com ← 电子邮箱,可随意填
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []: ← 可以不输入
An optional company name []: ← 可以不输入

3.备份一份服务器密钥文件

cp server.key server-bak.key

4.去除文件口令

openssl rsa -in server-bak.key -out server.key

5.生成证书文件server.crt

openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
posted @ 2022-05-07 16:08  温茶又折花  阅读(309)  评论(0编辑  收藏  举报