为什么在创建 CSR 时使用私钥?

Why private key is used amidst creation of CSR?

创建 CSR 主要是为了创建具有可信 public 密钥的证书。

在创建 CSR 之前,

我们创建一个私钥

openssl genrsa -out key.pem 1024

然后使用该私钥(key.pem)创建一个CSR(req.pem)请求。

openssl req -new -key key.pem -out req.pem

编辑:

我看到 docker 引擎安装了根证书、服务器证书和与 CSR 一起使用的私人证书

在提交CSR时提供私钥(key.pem作为输入)的确切目的是什么?因为证书应该用父私钥签名

创建CSR时是否需要私钥(key.pem)生成相应的public密钥?

是否使用私钥(key.pem)加密CSR并将生成的签名附加到CSR?

PKCS#10 认证请求 (RFC 2986) 的结构粗略地描述为:

Request:
    Info:
        Version
        Name
        PublicKey
        Attributes
    SignatureAlgorithmIdentifier
    Signature

这些属性是请求的属性,其中一个属性可能是您为生成的证书请求的属性。

CA 可以根据自己的选择从 CSR 那里得到多少尊重。例如,StartSSL 只读出 public 关键信息,并丢弃了 CSR 的其余部分——他们需要的一切都基于您从他们的网站 UI 和您的帐户状态的请求。

一般来说,CA 不会忽略 public 密钥值,因为如果他们为您声明了一个新的密钥对,他们需要弄清楚您应该如何获得私钥.因此,public 关键部分需要存在且正确。 OpenSSL的命令可以通过读取私钥得到public键值,然后嵌入到CSR中。

您需要私钥的第二个原因是签署请求。我断言请求被签名的主要原因是 force/strongly-suggest 你在这个阶段保存了私钥,所以你不会在几分钟后回来“请撤销这个新证书,我已经丢失了私钥”请求。 RFC(也)有这样的说法:

Note 2 - The signature on the certification request prevents an entity from requesting a certificate with another party's public key. Such an attack would give the entity the minor ability to pretend to be the originator of any message signed by the other party. This attack is significant only if the entity does not know the message being signed and the signed part of the message does not identify the signer. The entity would still not be able to decrypt messages intended for the other party, of course.