7.8. 创建并配置 SubCA (第二部分)
本节继续进行 SubCA 安装,假设您已安装了 OCSP 实例。这样,subCA 的角色用户证书和 TLS 服务器证书将是指向 OCSP 实例的 AIA 扩展。
7.8.1. 发出非引导代理用户证书 复制链接链接已复制到粘贴板!
在本节中,我们将使用 SubCA 的 bootstrap admin 证书来发布证书 rsa_SubCA_AgentV (代理用户 jsmith),仅限于 PKI 代理角色特权。然后,这个证书可用于批准将来的 CMC 证书请求。
前提条件
- 以 root 用户身份登录 rhcs10.example.com。
为 pki 代理用户创建代理证书
-
按照 第 7.12.3 节 “代理用户” 所述的步骤进行操作,获取为 pki 代理用户(如 jsmith)发布的代理证书(本例中为 rsa_SubCA_AgentV)。注意:如该部分开头的说明,如果您只是测试/评估产品,为方便起见,而不是使用非 root 用户(如 jsmith),您可以以 root 用户身份为 rsa_SubCA_AgentV 生成 CSR,与 bootstrap 用户(
/root/.dogtag/pki_rsa_rsa_bootstrap_rsa_bootstrap_rsa_bootstrap_rsa_bootstrap_rsa_bootstrap_rsa_bootstrap/certs_db)在同一证书数据库中生成 CSR,并进一步导入到同一证书数据库中。如果您选择这样做,请在以下说明中相应地替换 user/certs_db。
验证:
显示已安装的 SubCA 的状态:
# pki-server status rhcs10-RSA-SubCA请注意安全代理、Admin 和 pkiconsole URL。
执行 sanity 测试来验证新的 SubCA Admin 证书是否已成功添加:
首先,查找在 第 7.7.7.4 节 “测试 CRL 发布” 中创建 user1 证书的序列号:
# pki -p 31443 -h rhcs10.example.com ca-cert-find --uid user1使用 SubCA 代理的凭证将保存放在
user1的证书上:# pki -d /home/jsmith/certs_db -n rsa_SubCA_AgentV -p 31443 -h rhcs10.example.com ca-cert-hold <user1 serial number>
-
确保在
rhcs10.example.com上可以访问 SubCA 的 EE 页面。
7.8.2. 替换临时 DS 证书(SubCA) 复制链接链接已复制到粘贴板!
SubCA 安装完成后,它可以为 Directory 服务器发布官方 SSL 服务器证书来替换临时证书。为目录服务器证书创建证书签名请求(CSR),然后使用 SubCA 代理用户(rsa_SubCA_AgentV)凭证将此请求提交到 CA。
确保您使用 DS 服务器的 FQDN,如 cn=rhds11.example.com / host=rhds11.example.com。
为真实 DS 证书生成 CSR
在 rhds11.example.com 上,为真实 DS 证书生成 PKCS10 证书签名请求:
停止 DS :
# dsctl slapd-CC-RSA-SubCA-LDAP stop使用
certutil工具生成 CSR:# certutil -R -d /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP -s "CN=rhds11.example.com" -g 2048 -f /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/pwdfile.txt -a -o /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/Server-Cert-subca.csr -z /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/noise.txt重要编辑上面获取的
Server-Cert-subca.csr输出文件,以删除"Begin Certificate Request"前的几行。例如:
# vi /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/Server-Cert-subca.csrCSR 文件必须以"-----BEGIN CERTIFICATE REQUEST-----"行开头,并以"-----END CERTIFICATE REQUEST-----"行结尾。
启动 DS :
# dsctl slapd-CC-RSA-SubCA-LDAP start远程将
Server-Cert-subca.csr文件复制到 CA 所在的系统中。例如:# scp /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/Server-Cert-subca.csr root@rhcs10.example.com:/root/.dogtag/pki_rsa_bootstrap/certs_db/Server-Cert-subca.csr
发出真实 DS 证书
在 rhcs10.example.com 上,发布实际的 SSL 服务器证书:
生成 CMC 请求:
创建
CMCRequest配置文件。例如:# vim /root/.dogtag/pki_rsa_bootstrap/certs_db/cmc.dirsrv-subca_pkcs10.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. ### Multiple files are supported. They must be separated by a space. ### For input on a different host, specify where to find the CSR. input=/root/.dogtag/pki_rsa_bootstrap/certs_db/Server-Cert-subca.csr ### output: full path for the CMC request in binary format ### For output on a different host, specify the destination. output=/root/.dogtag/pki_rsa_bootstrap/certs_db/cmc.dirsrv-subca_pkcs10.req ### tokenname: name of the token where the agent signing cert can be found (default is internal) tokenname=internal ### nickname: nickname for the agent certificate that will be used to sign the CMC full request. nickname=PKI Bootstrap Administrator for RSA-SubCA ### dbdir: directory for cert8.db, key3.db and secmod.db dbdir=/root/.dogtag/pki_rsa_bootstrap/certs_db ### password: password for cert8.db that stores the agent certificate password=SECret.123 ### format: request format, either pkcs10 or crmf format=pkcs10使用
CMCRequest命令生成请求:# CMCRequest /root/.dogtag/pki_rsa_bootstrap/certs_db/cmc.dirsrv-subca_pkcs10.cfg cert/key prefix = path = /root/.dogtag/pki_rsa_bootstrap/certs_db CryptoManger initialized token internal logged in... got signerCert: PKI Bootstrap Administrator for RSA-SubCA createPKIData: begins k=0 createPKIData: format: pkcs10 useSharedSecret is false... signData: begins: getPrivateKey: got signing cert signData: got signer privKey createSignedData: begins getSigningAlgFromPrivate: begins. getSigningAlgFromPrivate: found signingKeyType=RSA getSigningAlgFromPrivate: using SignatureAlgorithm: RSASignatureWithSHA256Digest createSignedData: digest created for pkidata createSignedData: digest algorithm =RSASignatureWithSHA256Digest createSignedData: building cert chain signData: signed request generated. getCMCBlob: begins getCMCBlob: generating signed data The CMC enrollment request in base-64 encoded format: . . . Output omitted . . . The CMC enrollment request in binary format is stored in /root/.dogtag/pki_rsa_bootstrap/certs_db/cmc.dirsrv-subca_pkcs10.req
提交 CMC 请求:
创建
HttpClient配置文件。例如:# vim /root/.dogtag/pki_rsa_bootstrap/certs_db/HttpClient_dirsrv-subca.cfg### host: host name for the http server host=rhcs10.example.com ### port: port number port=31443 ### 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=/root/.dogtag/pki_rsa_bootstrap/certs_db/cmc.dirsrv-subca_pkcs10.req ### output: full path for the response in binary format output=/root/.dogtag/pki_rsa_bootstrap/certs_db/cmc.dirsrv-subca_pkcs10.resp ### tokenname: name of the token where the SSL client authentication cert can be found (default is internal) ### This parameter will be ignored if secure=false tokenname=internal ### dbdir: directory for cert8.db, key3.db and secmod.db ### This parameter will be ignored if secure=false dbdir=/root/.dogtag/pki_rsa_bootstrap/certs_db ### clientmode: true for client authentication, false for no client authentication ### This parameter will be ignored if secure=false clientmode=true ### password: password for cert8.db ### This parameter will be ignored if secure=false and clientauth=false password=SECret.123 ### nickname: nickname for client certificate ### This parameter will be ignored if clientmode=false nickname=PKI Bootstrap Administrator for RSA-SubCA ### servlet: servlet name servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caCMCserverCertWithCRLDP注意对于 EC 证书,通过设置来使用 ECC 配置集:
servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caCMCECserverCertWithCRLDP使用
HttpClient命令提交请求:# HttpClient /root/.dogtag/pki_rsa_bootstrap/certs_db/HttpClient_dirsrv-subca.cfg Total number of bytes read = 3096 after SSLSocket created, thread token is NSS FIPS 140-2 User Private Key client cert is not null handshake happened writing to socket ##Response Headers begin## HTTP/1.1 200 Content-Type: application/pkcs7-mime Content-Length: 2492 Date: Tue, 29 Sep 2020 15:20:21 GMT Connection: close ##end## . . . Output omitted . . . The response in binary format is stored in /root/.dogtag/pki_rsa_bootstrap/certs_db/cmc.dirsrv-subca_pkcs10.resp
处理 CMC 响应:
使用
CMCResponse处理响应,以 PEM 格式单独以链的形式显示所有证书:重要使用 "-v" 选项运行 CMCResponse 将链中每个证书的 PEM 返回为 Cert:0, Cert:1 等。在所有 PEM 下,输出也会以用户打印格式显示链中的每个证书。由于证书没有以固定顺序显示,因此为了确定其在链中的位置,您必须检查每个 "Certificate" 下的"Subject: "。对应的 PEM 显示在上面的同一位置。
# CMCResponse -d /root/.dogtag/pki_rsa_bootstrap/certs_db -i /root/.dogtag/pki_rsa_bootstrap/certs_db/cmc.dirsrv-subca_pkcs10.resp -v Cert:0 ... === Cert:1 ... === Cert:2 ... === Certificates: Certificate: Data: Version: v3 Serial Number: 0xA383694 Signature Algorithm: SHA256withRSA - 1.2.840.113549.1.1.11 Issuer: CN=CA Signing Certificate,OU=rhcs10-RSA-SubCA,O=Example-rhcs10-RSA-SubCA Validity: Not Before: Tuesday, April 5, 2022 8:41:36 AM EDT America/New_York Not After: Monday, March 25, 2024 8:41:36 AM EDT America/New_York Subject: CN=rhds11.example.com . . . Output omitted . . . Certificate: Data: Version: v3 Serial Number: 0x5C8FAD4 Signature Algorithm: SHA256withRSA - 1.2.840.113549.1.1.11 Issuer: CN=CA Signing Certificate,OU=rhcs10-RSA-RootCA,O=Example-rhcs10-RSA-RootCA Validity: Not Before: Tuesday, April 5, 2022 8:36:21 AM EDT America/New_York Not After: Saturday, April 5, 2042 8:36:21 AM EDT America/New_York Subject: CN=CA Signing Certificate,OU=rhcs10-RSA-RootCA,O=Example-rhcs10-RSA-RootCA . . . Output omitted . . . Certificate: Data: Version: v3 Serial Number: 0x80296C3 Signature Algorithm: SHA256withRSA - 1.2.840.113549.1.1.11 Issuer: CN=CA Signing Certificate,OU=rhcs10-RSA-RootCA,O=Example-rhcs10-RSA-SubCA Validity: Not Before: Tuesday, April 5, 2022 8:39:43 AM EDT America/New_York Not After: Friday, April 5, 2041 8:39:43 AM EDT America/New_York Subject: CN=CA Signing Certificate,OU=rhcs10-RSA-SubCA,O=Example-rhcs10-RSA-RootCA . . . Output omitted . . . Number of controls is 1 Control #0: CMCStatusInfoV2 OID: {1 3 6 1 5 5 7 7 25} BodyList: 1 Status: SUCCESS CMC Full Response.将新
Server-CertDS 证书保存到 bootstrap 证书目录(例如/root/.dogtag/pki_rsa_bootstrap/certs_db/)中的文件中。.pem文件必须以 header-----BEGIN CERTIFICATE-----开头,并以 footer-----END CERTIFICATE-----结束。例如:# vi /root/.dogtag/pki_rsa_bootstrap/certs_db/Server-Cert-subca.pem其中
Server-Cert-subca.pem是 Directory Server 实例的新的Server-Cert证书,充当 SubCA 的 internaldb。注意RootCA 的签名证书应与以下命令的输出匹配:
# certutil -L -d /var/lib/pki/rhcs10-RSA-RootCA/alias/ -n "CA Signing Cert - rhcs10-RSA-RootCA" -a
远程将新的
Server-Cert证书复制到 rhds11.example.com。例如:# scp /root/.dogtag/pki_rsa_bootstrap/certs_db/Server-Cert-subca.pem root@rhds11.example.com:/etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/
替换临时 DS 证书
在 rhds11.example.com 上,将临时 DS 证书替换为实际的 DS 证书:
停止 SubCA 的 LDAP 实例:
# dsctl slapd-CC-RSA-SubCA-LDAP stop将
dirsrv目录的内容保存到备份目录中:# cp -r /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/ /etc/dirsrv/save-rsa/slapd-CC-RSA-SubCA-LDAP/删除旧的 DS 证书:
# certutil -D -d /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/ -f /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/pwdfile.txt -n "Server-Cert"# certutil -D -d /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/ -f /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/pwdfile.txt -n "Self-Signed-CA"逐个导入新创建的 DS 证书和 CA 证书。例如:
# certutil -d /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/ -f /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/pwdfile.txt -A -t "CT,C,C" -n "CA Signing Cert - rhcs10-RSA-RootCA" -i /opt/pki_rsa/rootCA.pem# certutil -d /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/ -f /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/pwdfile.txt -A -t "CT,C,C" -n "CA Signing Cert - rhcs10-RSA-SubCA" -i /opt/pki_rsa/subCA.pem# certutil -d /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/ -f /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/pwdfile.txt -A -t "u,u,u" -n "Server-Cert" -i /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/Server-Cert-subca.pem列出证书:
# certutil -L -d /etc/dirsrv/slapd-CC-RSA-SubCA-LDAP/ Certificate Nickname Trust Attributes SSL,S/MIME,JAR/XPI CA Signing Cert - rhcs10-RSA-RootCA CT,C,C CA Signing Cert - rhcs10-RSA-SubCA CT,C,C Server-Cert u,u,u启动 DS :
# dsctl slapd-CC-RSA-SubCA-LDAP start测试以确认 LDAP 服务器已启动并在运行(如果是单独的系统,则在 CA 主机上进行测试):
# ldapsearch -x -D "cn=Directory Manager" -H ldaps://rhds11.example.com:7636 -b "dc=example,dc=com" -w SECret.123如果在单独的系统上测试,请在
ldapsearch命令前面包含 CA 证书链,例如:# LDAPTLS_CACERT=/opt/pki_rsa/ca-chain.pem ldapsearch -x -D "cn=Directory Manager" -H ldaps://rhds11.example.com:7636 -b "dc=example,dc=com" -w SECret.123
删除 SubCA 实例的临时 DS 证书的信任
在 rhcs10.example.com 上,从 SubCA 实例数据库中删除临时 DS 证书:
停止 SubCA:
# pki-server stop rhcs10-RSA-SubCA列出证书:
# certutil -L -d /var/lib/pki/rhcs10-RSA-SubCA/alias/ Certificate Nickname Trust Attributes SSL,S/MIME,JAR/XPI DS temp CA certificate CT,C,C ...从 nssdb 中删除临时证书:
# certutil -D -d /var/lib/pki/rhcs10-RSA-SubCA/alias/ -n "DS temp CA certificate"
启用证书撤销检查
现在,Directory 服务器证书已被替换,我们可以通过启用证书撤销检查来查看在 CA 启动过程中检测到 CRL 发布点:
要启用证书撤销检查,在相应的
/var/lib/pki/rhcs10-RSA-SubCA/conf/server.xml文件中:将
enableOCSP或enableRevocationCheck设置为true:enableOCSP=true or enableRevocationCheck=true另外,删除这两个参数及其分配的值:
ocspResponderURL ocspResponderCertNickname
通过编辑 CA 的
CS.cfg文件并将以下内容设置为false来禁用旧的撤销检查方法:auths.revocationChecking.enabled=false启动 SubCA 实例:
# pki-server start rhcs10-RSA-SubCA
验证 CRL 发布点
现在,我们使用配置文件 caCMCserverCertWithCRLDP 替换了从属 CA 的目录服务器的 server-cert,在启动与其内部目录服务器的连接时,这有效地触发 CA 引用的 CRL 分发点。
本节提供了一种基本方法来验证 CA 中的 CRL 分发点设置(请参阅 第 7.6.6 节 “配置对 CRL 分发点的支持”):
检查基于文件的 CRL 发布:
# ls -l /var/lib/pki/rhcs10-RSA-SubCA/crl total 4 -rw-r--r--. 1 pkiuser pkiuser 573 Jun 21 18:43 ServerCertCRL-20240621-175339.der lrwxrwxrwx. 1 pkiuser pkiuser 67 Jun 21 18:43 ServerCertCRL.crl -> /var/lib/pki/rhcs10-RSA-SubCA/crl/ServerCertCRL-20240621-175339.der显示并验证 CRL 的内容
# BtoA /var/lib/pki/rhcs10-RSA-SubCA/crl/ServerCertCRL.crl /var/lib/pki/rhcs10-RSA-SubCA/crl/ServerCertCRL.bin # PrettyPrintCrl /var/lib/pki/rhcs10-RSA-SubCA/crl/ServerCertCRL.bin Certificate Revocation List: Data: Version: v2 Signature Algorithm: SHA256withRSA - 1.2.840.113549.1.1.11 Issuer: CN=CA Signing Certificate,OU=rhcs10-RSA-SubCA,O=Example-rhcs10-RSA-RootCA This Update: Friday, June 21, 2024 5:53:39 PM EDT America/New_York Next Update: Friday, June 21, 2024 9:00:00 PM EDT America/New_York Revoked Certificates: Extensions: Identifier: CRL Number - 2.5.29.20 Critical: no Number: 4 Signature: Algorithm: SHA256withRSA - 1.2.840.113549.1.1.11 Signature: 9E:8A:E1:38:C4:B8:EF:E0:34:2A:92:2D:96:F2:7C:DF: 71:F8:4E:8E:EF:AD:C1:CA:65:86:BD:27:45:1C:7E:DD: 32:E6:16:94:83:E9:83:3F:24:1F:A1:89:74:7E:70:B6: 04:20:36:7F:45:9C:A9:6C:7D:63:37:A3:9F:FD:F2:E1: CE:64:FA:D8:75:82:09:42:AB:B6:83:73:40:1A:C7:98: 53:BC:65:81:3C:C3:71:D2:12:F9:A6:EA:00:80:B7:D8: A9:56:37:CD:CF:B9:59:64:B1:7F:31:39:16:11:1C:DC: 93:64:87:F9:97:CC:EF:58:23:92:77:FC:2E:22:3A:57: AA:D7:7B:D1:1E:2B:3F:AE:FF:17:1A:62:C4:0C:A0:1E: 0D:68:00:C4:68:4C:B5:27:4D:4B:DB:33:17:AC:8C:DF: 8D:FE:77:EE:B9:B1:17:55:8F:42:A2:5C:84:1B:6F:B8: 82:A6:F6:6E:E9:10:37:50:94:C4:33:D3:3C:18:22:7C: D6:6E:5E:89:34:E1:55:F5:80:F6:8F:B9:49:AE:A0:86: 2E:B5:8A:B1:00:8C:B0:4C:81:37:A6:BA:D1:7D:77:81: F3:68:6C:16:D6:0A:BA:E7:F6:65:4F:44:A1:5B:31:0F: C2:F7:F9:FE:DC:55:BA:38:F2:AE:AA:34:9E:D0:7D:64: E1:90:68:E2:68:DE:C9:D0:90:26:56:6B:3A:74:AF:E8: CA:55:AE:E8:A1:DF:81:D1:E4:C8:46:DD:E3:12:6D:46: BE:A5:F2:C4:12:4E:15:D5:0F:30:10:3D:77:62:A2:41: F6:85:77:6F:EF:5C:78:0C:FE:F1:C5:4B:C5:C4:69:B5: 84:0A:7B:4B:E3:D7:39:9A:66:43:AB:E9:DD:25:8E:EA: 58:2F:AD:1D:D4:CD:1A:EE:50:73:B2:0C:F1:29:67:B3: 2D:49:E1:54:95:51:9A:36:82:C3:D2:3F:32:7E:73:20: 86:0F:28:6F:CC:89:9F:DF:4A:A9:64:CD:30:4A:80:EE
不要删除 CRL 文件(soft link file ServerCertCRL.crl,及其关联的 der 文件)。
如果您遇到缺少 CRL 文件的情况,或者意外从 /var/lib/pki/rhcs10-RSA-SubCA/crl/ 中删除,防止 CA 启动,请按照以下步骤重新生成 CRL 文件:
停止 CA 服务。
# pki-server stop rhcs10-RSA-SubCA-
在 CA 的
server.xml中,将enableRevocationCheck或enableOCSP参数设置为false(如果它当前设置为true)。 -
在 CA 的
CS.cfg中,将ca.crl.ServerCertCRL.publishOnStart=参数设置为true。 启动 CA 服务以重新生成缺少的 CRL 文件:
# pki-server start rhcs10-RSA-SubCA- 恢复 CRL 文件后,再次停止 CA 服务。
-
在 CA 的
CS.cfg中,将ca.crl.ServerCertCRL.publishOnStart=参数恢复为false。 -
在 CA 的
server.xml中将enableRevocationCheck或enableOCSP参数设置为true。 - 再次启动 CA 服务以应用更改。
按照以下步骤,您将成功恢复缺少的 CRL 文件,并确保 CA 可以正确启动。
验证 CA 是否正常工作
列出 CA 中的证书:
# pki -p 31443 ca-cert-find以 bootstrap admin 用户身份,列出 SubCA 中的用户:
# pki -d /root/.dogtag/pki_rsa_bootstrap/certs_db/ -c SECret.123 -p 31443 -n "PKI Bootstrap Administrator for RSA-SubCA" ca-user-find
7.8.3. 增加 SubCA pkiconsole 超时 复制链接链接已复制到粘贴板!
在 rhcs10.example.com 上:
停止 SubCA:
# pki-server stop rhcs10-RSA-SubCA编辑
/var/lib/pki/rhcs10-RSA-SubCA/conf/server.xml以增加超时时间:<Connector name="Secure" port="31443" … connectionTimeout="3000000"启动 SubCA:
# pki-server start rhcs10-RSA-SubCA
7.8.5. 检查随机序列号 复制链接链接已复制到粘贴板!
确保所有子系统证书都有随机序列号:
- 访问 SubCA 的 EE 页面,并列出证书以确认它们有随机序列号。
另外,您可以使用以下命令检查随机序列号:
# pki -p 31443 ca-cert-find | grep -i serial
7.8.6. 创建其他 SubCA 角色用户 复制链接链接已复制到粘贴板!
我们之前已经为 rsa_SubCA_AgentV 创建了 代理 角色用户和证书。
另外,您可以按照 第 7.12 节 “创建 PKI 角色用户” 中的步骤为 admin 和 audit 角色创建其他单角色用户。
7.8.7. 使用客户端身份验证登录到 SubCA pkiconsole 复制链接链接已复制到粘贴板!
-
使用
sslclientauth配置 SubCA 并导入角色用户证书,如 第 7.13.6 节 “使用客户端身份验证配置 pkiconsole 登录” 所述。 使用角色用户的客户端身份验证证书登录到
pkiconsole:# pkiconsole -d <home .redhat-idm-console dir> -n <client cert> https://rhcs10.example.com:31443/ca然后从列表中选择角色用户证书别名,如 rsa_SubCA_AdminV。登录到控制台应该可以成功。
7.8.8. 安装后 复制链接链接已复制到粘贴板!
如果要安装其他 RHCS 实例,请继续下一小节。完成所有需要的 RHCS 实例安装后,请访问 第 7.13 节 “安装后” 以完成额外的设置。