linux服务器上生成CSR和KEY

CSR文件用来申请证书(提供给证书供应商)

KEY文件是私钥,用来配置ssl(放到服务器)

CERT是证书供应商颁发的证书(放到服务器)


CSR(证书请求文件) 包含申请证书所需要的相关信息,其中最重要的是域名,填写的域名必须是你要https方式访问的那个域名。如abc.com 或 web.abc.com

 
下面介绍生成key和csr的过程,首先使用下面的命令生成CSR 和 KEY两个文件。
 
openssl req -nodes -newkey rsa:2048 -keyout myserver.key -out server.csr
 
这个命令将会生成两个文件,myserver.key 是密钥文件,小心保存好这个文件。安装SSL证书的时候要用到。
 
执行上面的命令后,你必须根据提示输入相应的信息,如域名等等,按照提示一步一步操作,最后生成这两个文件。
 
 
Country Name (2 letter code) [AU]:  CN  (国家代码)
State or Province Name (full name) [Some-State]:  BJ  (省)
Locality Name (eg, city) []:  BJ   (城市)
Organization Name (eg, company) [Internet Widgits Pty Ltd]:  iHost (企业/组织)
Organizational Unit Name (eg, section) []:  IT  (部门)
Common Name (eg, YOUR name) []:  ibaohost.com   (域名/请正确填写)
Email Address []:  (可直接回车)
Please enter the following 'extra' attributes to be sent with your certificate request
 
A challenge password []:   (直接回车)
An optional company name []:  (直接回车)
Use the name of the web-server as Common Name (CN). If the domain name (Common Name) is mydomain.com append the domain to the hostname (use the fully qualified domain name).
 
其中的Email Address  和 A challenge password 可以留空,不必填写,直接回车。以上需要填写的内容,如果你不清楚应该怎么填写, 除了域名,其他的你可以按照上面的内容填写。
 

你可以使用命令 cat server.csr 查看该文件内容。并复制该文件全部内容。另外一个文件myserver.key 并务必保存好。如果你把这个key搞丢了,等你证书申请下来,你会发现没有key是无法安装的。


原文地址:https://blog.csdn.net/bolg_hero/article/details/45191595

猜你喜欢

转载自blog.csdn.net/sinat_18755913/article/details/79709091