CSR 和 CA 的介绍

创建 certificate signing request (CSR) 【证书签发请求】是获取签发证书的第一步。创建后的 CSR 文件包含签发请求者的信息(如:国家、城市、组织、公用名等)。向 Certificate Authority (CA) 【证书机构】提交请求后,CA 会根据 CSR 包含的信息为 公用名 创建并签发证书。

Refer: https://www.globalsign.com/en/blog/what-is-a-certificate-signing-request-csr

创建一个 CSR 文件及其私钥

你需要提前安装 Openssl 以使用其自带的 CSR 创建功能。

执行签发命令

openssl req -new -newkey rsa:2048 -nodes -keyout example.com.key -out example.com.csrCode language: CSS (css)

参数说明

  • req 使用证书签发请求功能。
  • -newkey rsa:2048 创建 2048 位的 RSA 密钥。
  • -nodes 不要加密密钥。
  • -keyout example.com.key 指定创建私钥的文件路径。
  • -out example.com.csr 指定 CSR 的文件路径。

Refer: https://www.tecmint.com/generate-csr-certificate-signing-request-in-linux/

关于其他位的RSA密钥及其安全情况,请参阅 https://en.wikipedia.org/wiki/RSA_numbers#RSA-2048

注意,由于 CA 签发后的证书依赖创建 CSR 时的私钥,故请妥善保存 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) [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 (e.g. server FQDN or YOUR name) []:
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:Code language: JavaScript (javascript)

根据需要进行填写即可,全部完成后,Openssl 将保存 CSR 及其私钥至命令参数中指定的路径。

提交 CSR 文件至 CA

CSR 文件的示例

-----BEGIN CERTIFICATE REQUEST-----
AAAAAAAAAAABBBBBBCCCCCCCCCCCCCCCC
.....
-----END CERTIFICATE REQUEST-----

将该文件或文件内容上传至 CA 指定位置即可。

完成

CA 根据 CSR 创建证书请求并发出用户验证请求,用户使用指定方式验证域名所有权(DV)或其他后,CA 将签发证书。使用创建 CSR 时生成的密钥与生成后的证书搭配即可。

分类: OPENSSL

0 条评论

发表回复

Avatar placeholder

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据