linux服务器上生成CSR和KEY


CSR表示“ 证书签名请求 ”,这个该证书将用于服务器上。一个CSR包含有关您的组织和域名,地方和国家,将包含在证书中的公钥信息。 本文有3个简单的步骤来创建CSR上的Linux系统(证书签名请求)。您可以选择以下之一。

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

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

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

1.先创建个文件夹,然后进入这个文件夹执行命令:

  mkdir  ssl

  cd ssl

2.执行命令:

  openssl req -nodes -newkey rsa:2048 -keyout myserver.key -out server.csr

    执行完会出现一些要输入的信息:

  

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 可以留空,不必填写,直接回车。以上需要填写的内容,如果你不清楚应该怎么填写,除了域名,其他的你可以按照上面的内容填写。

3.执行完 命令后  ,输入命令: ls

  可以看到生成的key和csr文件

  

  执行这些需要在服务器上装了ssl。

下面还有一种方法:简便的三条命令:

yum install openssl   安装
openssl genrsa -out howtoing.com.key 2048   生成key文件  2048位
openssl req -new -key howtoing.com.key -out howtoing.com.csr   

howtoing.com可以改成自己的文件名。
 
 
 
原文地址:https://www.cnblogs.com/cx-code/p/10431277.html