5.5. 使用 CMC 提交证书请求
本节描述了通过 CMS (CMC)使用证书管理注册证书的步骤。
有关使用 CMC 配置和注册证书的通用信息,请参考:
CMC 注册可以通过各种方式来满足不同场景的要求。第 5.5.2 节 “CMC 注册过程” Red Hat Certificate System 规划、安装和部署指南中的使用 CMC 补充部分。另外,第 5.5.3 节 “实际 CMC 注册场景” 部分可让管理员决定在哪些场景中应使用哪些机制。
5.5.1. 使用 CMC 注册
CMC 注册允许注册客户端使用 CMCAuth 插件进行身份验证,该插件使用代理证书预签名证书。当收到使用代理证书签名的有效请求时,证书管理器会自动发布证书。
CMC 注册会被默认启用。除非更改了配置,否则应该不需要启用 CMC 注册身份验证插件或配置文件。
CMCAuth 身份验证插件还为客户端提供 CMC 吊销。CMC 吊销允许客户端具有代理证书签名的证书请求,然后将此类请求发送到证书管理器。当收到使用代理证书签名的有效请求时,证书管理器会自动撤销证书。CMC 吊销可以使用 CMCRevoke
命令行工具创建。有关 CMCRevoke
的更多信息,请参阅 第 7.2 节 “执行 CMC 吊销”。
CMC 请求可以通过浏览器最终用户形式提交,或者使用 HttpClient
等工具将请求发布到相应的配置文件。CMCRequest
工具生成签名的证书请求,然后使用 HttpClient
工具或浏览器终端形式自动注册和接收证书。
CMCRequest
工具具有简单的命令语法,其所有配置在 .cfg
输入文件中提供:
CMCRequest /path/to/file.cfg
也可以使用 CMCEnroll
工具创建单个 CMC 注册,语法如下:
CMCEnroll -d /agent's/certificate/directory -h password -n cert_nickname -r certrequest.file -p certDB_passwd [-c "comment"]
这些工具在 CMCEnroll (1)
man page 中进行了更详细的描述。
在引号中包含空格的值。
5.5.1.1. 测试 CMCEnroll
-
使用
certutil
工具创建证书请求。 - 将 PKCS the10 ASCII 输出复制到文本文件。
运行 CMCEnroll 工具。
例如,如果名为
request34.txt
的输入文件存储在浏览器数据库中,代理证书的证书通用名称为CertificateManagerAgentsCert
,且证书数据库的密码是secret
,命令如下所示:CMCEnroll -d ~jsmith/.mozilla/firefox/1234.jsmith -n "CertificateManagerAgentsCert" -r /export/requests/request34.txt -p secret
此命令的输出存储在一个文件中,文件名相同,
.out
附加到文件名中。通过终端实体页面提交签名证书。
打开 end-entities 页面。
https://server.example.com:8443/ca/ee/ca
- 从证书配置文件列表中选择 CMC 注册表单。
- 将输出文件的内容粘贴到此表单的 Certificate Request 文本区域中。
-
从粘贴内容中删除
-----BEGIN NEW CERTIFICATE REQUEST-----
和---END NEW CERTIFICATE REQUEST-----
。 - 填写联系信息并提交表单。
- 证书会立即处理并返回。
- 使用 agent 页面搜索新证书。
5.5.2. CMC 注册过程
使用以下常规流程使用 CMC 请求和发布证书:
使用以下格式之一创建证书签名请求(CSR):
- PKCS the10 格式
- 证书请求消息格式(CRMF)格式
有关以这些格式创建 CSR 的详情,请参考 第 5.2 节 “创建证书签名请求”。
将 admin 证书导入到客户端 NSS 数据库中。例如:
执行以下命令,从
.p12
文件提取 admin 客户端证书:$ openssl pkcs12 -in /root/.dogtag/instance/ca_admin_cert.p12 -clcerts -nodes -nokeys -out /root/.dogtag/instance/ca_admin_cert.crt
根据 Red Hat Certificate System 规划、安装和部署 指南中的管理证书/密钥加密策略 部分中的指导来验证并导入 admin 客户端证书:
$ PKICertImport -d . -n "CA Admin - Client Certificate" -t ",," -a -i /root/.dogtag/instance/ca_admin_cert.crt -u C
重要在导入 CA Admin 客户端证书前,请确保所有中间证书和 root CA 证书都已导入。
导入与证书关联的私钥。
$ pki -c password pkcs12-import --pkcs12-file /root/.dogtag/instance/ca_admin_cert.p12 --pkcs12-password-file /root/.dogtag/instance/ca/pkcs12_password.conf
为 CMC 请求创建配置文件,如
/home/user_name/cmc-request.cfg
,其内容如下:# NSS database directory where CA agent certificate is stored dbdir=/home/user_name/.dogtag/nssdb/ # NSS database password password=password # Token name (default is internal) tokenname=internal # Nickname for signing certificate nickname=subsystem_admin # Request format: pkcs10 or crmf format=pkcs10 # Total number of PKCS10/CRMF requests numRequests=1 # Path to the PKCS10/CRMF request # The content must be in Base-64 encoded format. # Multiple files are supported. They must be separated by space. input=/home/user_name/file.csr # Path for the CMC request output=/home/user_name/cmc-request.bin
详情请查看
CMCRequest (1)
手册页。创建 CMC 请求:
$ CMCRequest /home/user_name/cmc-request.cfg
如果命令成功,
CMCRequest
工具会将 CMC 请求存储在请求配置文件的output
参数中指定的文件中。为
HttpClient
创建配置文件,如/home/user_name/cmc-submit.cfg
,以在稍后的步骤中使用,将 CMC 请求提交到 CA。在创建的文件中添加以下内容:# PKI server host name host=server.example.com # PKI server port number port=8443 # Use secure connection secure=true # Use client authentication clientmode=true # NSS database directory where the CA agent certificate is stored. dbdir=/home/user_name/.dogtag/nssdb/ # NSS database password password=password # Token name (default: internal) tokenname=internal # Nickname of signing certificate nickname=subsystem_admin # Path for the CMC request input=/home/user_name/cmc-request.bin # Path for the CMC response output=/home/user_name/cmc-response.bin
重要在 nickname 参数中指定的证书的
nickname
必须与之前用于 CMC 请求的证书匹配。根据您请求的证书类型,将以下参数添加到上一步中创建的配置文件中:
servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=profile_name
例如,对于 CA 签名证书:
servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caCMCcaCert
重要当代理在下一步中提交 CMC 请求时,此参数中指定的配置集必须使用
CMCAuth
身份验证插件。在用户发起的注册中,配置集必须使用CMCUserSignedAuth
插件。详情请查看 第 11.3 节 “CMC 身份验证插件”。向 CA 提交 CMC 请求:
$ HttpClient /home/user_name/cmc-submit.cfg
要将 CMC 响应转换为 PKCS #7 证书链,请将 CMC 响应文件传递给
CMCResponse
工具的-i
参数。例如:$ CMCResponse -i /home/user_name/cmc-response.bin -o /home/user_name/cert_chain.crt
5.5.3. 实际 CMC 注册场景
本节论述了频繁的实际使用场景及其工作流,以便 CA 管理员能够决定在哪些情况下使用哪些 CMC 方法。
有关使用 CMC 注册证书的通用过程,请参阅 第 5.5.2 节 “CMC 注册过程”。
5.5.3.1. 获取系统和服务器证书
如果服务(如 LDAP 或 Web 服务器)需要 TLS 服务器证书,则此服务器的管理员会根据服务的文档创建 CSR,并将其发送到 CA 的代理以进行批准。这个过程使用 第 5.5.2 节 “CMC 注册过程” 中描述的步骤。另外,请考虑以下要求:
- 注册配置集
-
代理必须使用 第 11.3 节 “CMC 身份验证插件” 中列出的现有 CMC 配置集之一,或者创建一个使用
CMCAuth
身份验证机制的自定义配置集。 - CMC 签名证书
对于系统证书,CA 代理必须生成并签署 CMC 请求。为此,请将
CMCRequest
配置文件中的nickname
参数设置为 CA 代理的 nickname。注意CA 代理必须有权访问自己的私钥。
httpclient
TLS 客户端别名-
在
CMCRequest
实用程序的配置文件中使用与HttpClient
配置文件中的 TLS 客户端身份验证相同的证书。 httpclient
servlet
参数传递到
HttpClient
实用程序的配置文件中的servlet
指的是处理请求的 CMC servlet 和注册配置文件。根据您请求的证书类型,在上一步中创建的配置文件中添加以下条目之一:
对于 CA 签名证书:
servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caCMCcaCert
对于 KRA 传输证书:
servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caCMCkraTransportCert
对于 OCSP 签名证书:
servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caCMCocspCert
对于审计签名证书:
servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caCMCauditSigningCert
对于子系统证书:
对于 RSA 证书:
servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caCMCsubsystemCert
对于 ECC 证书:
servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caCMCECCsubsystemCert
对于 TLS 服务器证书:
对于 RSA 证书:
servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caCMCserverCert
对于 ECC 证书:
servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caCMCECCserverCert
对于管理员证书:
servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caFullCMCUserCert
更多详情:
- 当代理预签名 CSR 时,会被视为已建立 Identification,因为代理会检查 CSR 进行验证。不需要额外的 CMC 特定标识验证。
- PKCS the10 文件已经提供 Possession 信息,且不需要额外的 Possession (POP)。
-
在代理预批准的请求中,必须禁用
PopLinkWittnessV2
功能,因为代理会检查识别。
5.5.3.2. 获取用户的第一个签名证书
批准用户的第一个签名证书有两种方法:
- 代理为 CMC 请求签名。请参阅 第 5.5.3.2.1 节 “使用代理证书签署 CMC 请求”。
- 证书注册通过使用 Shared Secret 进行身份验证。请参阅 第 5.5.3.2.2 节 “使用共享 secret 为证书注册进行身份验证”。
5.5.3.2.1. 使用代理证书签署 CMC 请求
使用代理证书签名 CMC 请求的过程与 第 5.5.3.1 节 “获取系统和服务器证书” 中描述的系统和服务器证书相同。唯一的区别是用户创建 CSR 并将其发送到 CA 代理以进行批准。
5.5.3.3. 获取用户只加密的证书
本节论述了获取使用现有用户签名证书签名的只加密证书的工作流:
如果用户拥有多个用于不同用途的证书,其中有一个被签名,用户必须首先获取签名证书。用户拥有签名证书后,就可以将其用于参与 Of Origin,而无需设置并依赖 CMC 共享 Secret 机制。
有关获取用户第一个签名证书的详情,请参考 第 5.5.3.2 节 “获取用户的第一个签名证书”。
以用户身份:
- 使用存储在网络安全服务(NSS)数据库或包含用户的签名证书和密钥的智能卡中的加密令牌。
以 PKCS the10 或 CRMF 格式生成 CSR。
注意如果需要密钥归档,请使用 CRMF 格式。
生成 CMC 请求。
由于这是仅加密的证书,私钥无法签名。因此,不包含参与 Of Possession (POP)。因此,注册需要两个步骤:如果初始请求成功,则会导致带有
EncryptedPOP
控制的 CMC 状态。然后,用户使用响应并生成包含DecryptedPOP
控制并在第二步骤中提交该响应的 CMC 请求。对于第一步,除了默认参数外,用户必须在传递给
CMCRequest
程序的配置文件中设置以下参数:-
identification.enable
-
witness.sharedSecret
-
identityProofV2.enable
-
identityProofV2.hashAlg
-
identityProofV2.macAlg
-
popLinkWitnessV2.enable
(如果 CA 需要) -
如果 CA 需要,
popLinkWitnessV2.keyGenAlg
-
popLinkWitnessV2.macAlg
(如果 CA 需要) request.privKeyId
详情请查看
CMCRequest (1)
手册页。响应包含:
- CMC 加密的 POP 控制
-
CMCStatusInfoV2
控制为POP 所需的
错误 - 请求 ID
-
对于第二个步骤,除了默认参数外,用户必须在传递给
CMCRequest
程序的配置文件中设置以下参数:-
decryptedPop.enable
-
encryptedPopResponseFile
-
decryptedPopRequestFile
-
request.privKeyId
-
oaep=true
-
详情请查看
CMCRequest (1)
手册页。
5.5.3.3.1. 使用 Key Archival 仅包含只加密证书的示例
要使用密钥归档执行注册,请在 CRMF 请求中生成包含用户的加密私钥的 CMC 请求。以下流程假设该用户已经拥有签名证书。此签名证书的别名在配置文件中的配置文件中设置。
以下流程描述了与只加密密钥一起使用的双端颁发,这些密钥无法用于签名。如果您使用可签署证书的密钥,请将 -q POP_SUCCESS 选项而不是 -q POP_NONE 传递给 CRMFPopClient
实用程序,以进行单行颁发。
有关将 CRMFPoPClient
与 POP_SUCCESS
搭配使用的说明,请参阅 第 5.2.1.3.1 节 “使用 CRMFPopClient
创建带有密钥 Archival 的 CSR” 和 第 5.2.1.3.2 节 “使用 CRMFPopClient
为基于 SharedSecret 的 CMC 创建 CSR”。
搜索 KRA 传输证书。例如:
$ pki cert-find --name KRA_transport_certificate_subject_CN
使用您在上一步中检索到的 KRA 传输证书的序列号,将证书存储在文件中。例如,要将带有 12345 序列号的证书存储在
/home/user_name/kra.cert
文件中:$ pki cert-show 12345 --output /home/user_name/kra.cert
使用
CRMFPopClient
工具:使用密钥归档创建 CSR:
切换到正在请求证书的用户或实体的证书数据库目录,例如:
$ cd /home/user_name/
使用
CRMFPopClient
实用程序创建一个 CRMF 请求,其中 RSA 私钥由 KRA 传输证书包装。例如,要将请求存储在/home/user_name/crmf.req
文件中:$ CRMFPopClient -d . -p token_password -n "cn=subject_name" -q POP_NONE -b kra.transport -w "AES KeyWrap/Wrapped" -v -o crmf.req -oaep
请注意命令显示的私钥的 ID。稍后的步骤中需要 ID 作为第二行配置文件中的
request.privKeyId
参数的值。注意如果为其配置了服务器,则 use
-oaep
。如果现代 HSM 首选 AES/CBC/PKCS5Padding,则使用 AES KeyWrap/WrapWrapped。
为
CRMRequest
工具创建一个配置文件,如/home/user_name/cmc.cfg
,其内容如下:#numRequests: Total number of PKCS10 requests or CRMF requests. numRequests=1 #input: full path for the PKCS10 request or CRMF request, #the content must be in Base-64 encoded format input=/home/user_name/crmf.req #output: full path for the CMC request in binary format output=/home/user_name/cmc.req #tokenname: name of token where agent signing cert can be found #(default is internal) tokenname=internal #nickname: nickname for user certificate which will be used #to sign the CMC full request. nickname=signing_certificate #dbdir: directory for cert9.db, key4.db and pkcs11.txt dbdir=/home/user_name/.dogtag/nssdb/ #password: password for cert9.db which stores the agent certificate password=password #format: request format, either pkcs10 or crmf format=crmf
创建 CMC 请求:
$ CMCRequest /home/user_name/cmc.cfg
如果命令成功,
CMCRequest
工具会将 CMC 请求存储在请求配置文件的output
参数中指定的文件中。为
HttpClient
创建配置文件,如/home/user_name/cmc-submit.cfg
,以在稍后的步骤中使用,将 CMC 请求提交到 CA。在创建的文件中添加以下内容:#host: host name for the http server host=server.example.com #port: port number port=8443 #secure: true for secure connection, false for nonsecure connection secure=true #input: full path for the enrollment request, the content must be in #binary format input=/home/user_name/cmc.req #output: full path for the response in binary format output=/home/user_name/cmc-response_round_1.bin #tokenname: name of token where TLS client authentication cert can be found #(default is internal) #This parameter will be ignored if secure=false tokenname=internal #dbdir: directory for cert9.db, key4.db and pkcs11.txt #This parameter will be ignored if secure=false dbdir=/home/user_name/.dogtag/nssdb/ #clientmode: true for client authentication, false for no client authentication #This parameter will be ignored if secure=false clientmode=true #password: password for cert9.db #This parameter will be ignored if secure=false and clientauth=false password=password #nickname: nickname for client certificate #This parameter will be ignored if clientmode=false nickname=signing_certificate #servlet: servlet name servlet=/ca/ee/ca/profileSubmitUserSignedCMCFull?profileId=caFullCMCUserSignedCert
向 CA 提交 CMC 请求:
$ HttpClient /home/user_name/cmc-submit.cfg
如果命令成功,
HTTPClient
实用程序会将 CMC 响应存储在 配置文件output
参数中指定的文件中。将响应文件传递给
CMCResponse
工具来验证响应。例如:$ CMCResponse -d /home/user_name/.dogtag/nssdb/ -i /home/user_name/cmc-response_round_1.bin
如果第一个旅行成功,
CMCResponse
会显示类似于如下的输出:Certificates: Certificate: Data: Version: v3 Serial Number: 0x1 Signature Algorithm: SHA256withRSA - 1.2.840.113549.1.1.11 Issuer: CN=CA Signing Certificate,OU=pki-tomcat,O=unknown00262DFC6A5E Security Domain Validity: Not Before: Wednesday, May 17, 2017 6:06:50 PM PDT America/Los_Angeles Not After: Sunday, May 17, 2037 6:06:50 PM PDT America/Los_Angeles Subject: CN=CA Signing Certificate,OU=pki-tomcat,O=unknown00262DFC6A5E Security Domain ... Number of controls is 3 Control #0: CMC encrypted POP OID: {1 3 6 1 5 5 7 7 9} encryptedPOP decoded Control #1: CMCStatusInfoV2 OID: {1 3 6 1 5 5 7 7 25} BodyList: 1 OtherInfo type: FAIL failInfo=POP required Control #2: CMC ResponseInfo requestID: 15
对于第二行,请为
DecryptedPOP
创建一个配置文件,如/home/user_name/cmc_DecryptedPOP.cfg
,该文件用于后续步骤。在创建的文件中添加以下内容:#numRequests: Total number of PKCS10 requests or CRMF requests. numRequests=1 #input: full path for the PKCS10 request or CRMF request, #the content must be in Base-64 encoded format #this field is actually unused in 2nd trip input=/home/user_name/crmf.req #output: full path for the CMC request in binary format #this field is actually unused in 2nd trip output=/home/user_name/cmc2.req #tokenname: name of token where agent signing cert can be found #(default is internal) tokenname=internal #nickname: nickname for agent certificate which will be used #to sign the CMC full request. nickname=signing_certificate #dbdir: directory for cert9.db, key4.db and pkcs11.txt dbdir=/home/user_name/.dogtag/nssdb/ #password: password for cert9.db which stores the agent #certificate password=password #format: request format, either pkcs10 or crmf format=crmf oaep=true decryptedPop.enable=true encryptedPopResponseFile=/home/user_name/cmc-response_round_1.bin request.privKeyId=-25aa0a8aad395ebac7e6a19c364f0dcb5350cfef decryptedPopRequestFile=/home/user_name/cmc.DecryptedPOP.req
创建
DecryptPOP
CMC 请求:$ CMCRequest /home/user_name/cmc.DecryptedPOP.cfg
如果命令成功,
CMCRequest
实用程序将 CMC 请求存储在请求配置文件中的decryptedPopRequestFile
参数中指定的文件中。为
HttpClient
创建配置文件,如/home/user_name/decrypted_POP_cmc-submit.cfg
,以便稍后的步骤使用 将DecryptedPOP
CMC 请求提交到 CA。在创建的文件中添加以下内容:#host: host name for the http server host=server.example.com #port: port number port=8443 #secure: true for secure connection, false for nonsecure connection secure=true #input: full path for the enrollment request, the content must be in binary format input=/home/user_name/cmc.DecryptedPOP.req #output: full path for the response in binary format output=/home/user_name/cmc-response_round_2.bin #tokenname: name of token where TLS client authentication cert can be found (default is internal) #This parameter will be ignored if secure=false tokenname=internal #dbdir: directory for cert9.db, key4.db and pkcs11.txt #This parameter will be ignored if secure=false dbdir=/home/user_name/.dogtag/nssdb/ #clientmode: true for client authentication, false for no client authentication #This parameter will be ignored if secure=false clientmode=true #password: password for cert9.db #This parameter will be ignored if secure=false and clientauth=false password=password #nickname: nickname for client certificate #This parameter will be ignored if clientmode=false nickname=singing_certificate #servlet: servlet name servlet=/ca/ee/ca/profileSubmitUserSignedCMCFull?profileId=caFullCMCUserCert
将
DecryptedPOP
CMC 请求提交到 CA:$ HttpClient /home/user_name/decrypted_POP_cmc-submit.cfg
如果命令成功,
HTTPClient
实用程序会将 CMC 响应存储在 配置文件output
参数中指定的文件中。要将 CMC 响应转换为 PKCS #7 证书链,请将 CMC 响应文件传递给
CMCResponse
工具的-i
参数。例如:$ CMCResponse -i /home/user_name/cmc-response_round_2.bin -o /home/user_name/certs.p7
或者,要以 PEM 格式显示单个证书,请将 -v 传递给实用程序。
如果第二个往返成功,
CMCResponse
会显示类似于如下的输出:Certificates: Certificate: Data: Version: v3 Serial Number: 0x2D Signature Algorithm: SHA256withRSA - 1.2.840.113549.1.1.11 Issuer: CN=CA Signing Certificate,OU=pki-tomcat,O=unknown00262DFC6A5E Security Domain Validity: Not Before: Thursday, June 15, 2017 3:43:45 PM PDT America/Los_Angeles Not After: Tuesday, December 12, 2017 3:43:45 PM PST America/Los_Angeles Subject: CN=user_name,UID=example,OU=keyArchivalExample ... Number of controls is 1 Control #0: CMCStatusInfo OID: {1 3 6 1 5 5 7 7 1} BodyList: 1 Status: SUCCESS