SSL证书制作

发布时间 2023-11-20 21:39:05作者: 不爱学的李泽信

SSL证书制作

一、生成私钥

openssl genrsa -idea -out server.key 2048

# 生成一个2048位的RSA私钥
# key的名称可自行修改

二、生成证书签名请求

openssl req -new -key server.key -out server.csr		# 名称可自行修改
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		# 国家代码,简写2个字符
State or Province Name (full name) []:ShanDong	# 所在省
Locality Name (eg, city) [Default City]:jinan	# 所在市
Organization Name (eg, company) [Default Company Ltd]:hanweb		# 所在组织
Organizational Unit Name (eg, section) []:hanweb		# 公司名 
Common Name (eg, your name or your server's hostname) []:192.168.233.128		#通用名称(例如服务器 FQDN 或您的姓名)域名/主机名
Email Address []:394476071@qq.com		#电子邮件地址

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:		#质询密码(可选字段)不建议
An optional company name []:hanweb		#可选的公司名称,不填也可以

三、生成自签名证书

openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt

# 生成一个有效期为 10年的自签名 SSL 证书。