csr文件用来申请证书(提供给证书供应商)key文件是私钥,用来配置ssl(放到服务器)cert是证书供应商颁发的证书(放到服务器)首先安装openssl支持: yum -y install gcc zlib zlib-devel opensslopenssl-devel
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]: (国家代码) state or province name (full name) [some-state]: (省) locality name (eg, city) []: (城市) organization name (eg, company) [internet widgits pty ltd]: (企业/组织) organizational unit name (eg, section) []: (部门) common name (eg, your name) []: (域名/请正确填写,abc.com请改成您的域名) email address []: [email protected] (输入邮箱地址,必须能接收邮件) 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).
其中的a challenge password 可以留空,不必填写,直接回车。以上需要填写的内容,如果您不清楚应该怎么填写,除了域名,其他的您可以按照上面的内容填写。 您可以使用命令 cat server.csr 查看该文件内容。并复制该文件全部内容。另外一个文件myserver.key 并务必保存好。如果您把这个key搞丢了,等您证书申请下来,您会发现没有key是无法安装的。 |