7.9. 创建并配置 KRA 实例


本节论述了针对 SubCA 安装和配置 KRA 实例。在本例中,KRA 安装在 rhcs10.example.com 上,其内部目录服务器位于 rhds11.example.com 上。

注意

确保文件 /opt/pki_rsa/ca-chain.pem 包含完整的 CA 证书链(SubCA 和 RootCA 证书):

# ls -l /opt/pki_rsa/ca-chain.pem

# cat /opt/pki_rsa/ca-chain.pem
Copy to Clipboard Toggle word wrap

7.9.1. 替换临时 DS 证书(KRA)

在安装 KRA 之前,我们为 KRA 的目录服务器发布官方 SSL 服务器证书,以取代临时 bootstrap。为此,我们首先要为目录服务器证书创建一个证书签名请求(CSR),然后将此请求提交到 CA。

注意

确保您使用 DS 服务器的 FQDN,如 cn=rhds11.example.com / host=rhds11.example.com

为真实 DS 证书生成 CSR

rhds11.example.com 上,为真实 DS 证书生成 PKCS10 证书签名请求:

  1. 停止 DS :

    # dsctl slapd-CC-RSA-KRA-LDAP stop
    Copy to Clipboard Toggle word wrap
  2. 使用 certutil 工具生成 CSR:

    # certutil -R -d /etc/dirsrv/slapd-CC-RSA-KRA-LDAP -s "CN=rhds11.example.com" -g 2048 -f /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/pwdfile.txt -a -o /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/Server-Cert-kra.csr -z /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/noise.txt
    Copy to Clipboard Toggle word wrap
    重要

    编辑上面获取的 Server-Cert-kra.csr 输出文件,以在"Begin Certificate Request"之前删除几行。例如:

    # vi /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/Server-Cert-kra.csr
    Copy to Clipboard Toggle word wrap

    CSR 文件必须以"-----BEGIN CERTIFICATE REQUEST-----"行开头,并以"-----END CERTIFICATE REQUEST-----"行结尾。

  3. 远程将 Server-Cert-kra.csr 文件复制到 CA 所在的系统中。例如:

    # scp /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/Server-Cert-kra.csr root@rhcs10.example.com:/root/.dogtag/pki_rsa_bootstrap/certs_db/Server-Cert-kra.csr
    Copy to Clipboard Toggle word wrap

发出真实 DS 证书

rhcs10.example.com 上,发布实际的 SSL 服务器证书:

  1. 生成 CMC 请求:

    1. 创建 CMCRequest 配置文件。例如:

      # vim /root/.dogtag/pki_rsa_bootstrap/certs_db/cmc.dirsrv-kra_pkcs10.cfg
      Copy to Clipboard Toggle word wrap
      ### 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-kra.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-kra_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
      Copy to Clipboard Toggle word wrap
    2. 使用 CMCRequest 命令生成请求:

      # CMCRequest /root/.dogtag/pki_rsa_bootstrap/certs_db/cmc.dirsrv-kra_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-kra_pkcs10.req
      Copy to Clipboard Toggle word wrap
  2. 提交 CMC 请求:

    1. 创建 HttpClient 配置文件。例如:

      # vim /root/.dogtag/pki_rsa_bootstrap/certs_db/HttpClient_dirsrv-kra.cfg
      Copy to Clipboard Toggle word wrap
      ### 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-kra_pkcs10.req
      
      ### output: full path for the response in binary format
      output=/root/.dogtag/pki_rsa_bootstrap/certs_db/cmc.dirsrv-kra_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=caCMCserverCert
      Copy to Clipboard Toggle word wrap
    2. 使用 HttpClient 命令提交请求:

      # HttpClient /root/.dogtag/pki_rsa_bootstrap/certs_db/HttpClient_dirsrv-kra.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-kra_pkcs10.resp
      Copy to Clipboard Toggle word wrap
  3. 处理 CMC 响应:

    1. 使用 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-kra_pkcs10.resp -v
      
      Cert:0
      ...
      ===
      Cert:1
      ...
      ===
      Cert:2
      ...
      ===
      Certificates:
      
        Certificate:
            Data:
                Version:  v3
                Serial Number: 0x34F6548
                Signature Algorithm: SHA256withRSA - 1.2.840.113549.1.1.11
                Issuer: CN=CA Signing Certificate,OU=rhcs10-RSA-SubCA,O=Example-rhcs10-RSA-RootCA
                Validity:
                    Not Before: Monday, September 25, 2023 8:28:24 PM EDT America/New_York
                    Not  After: Sunday, September 14, 2025 8:28:24 PM EDT America/New_York
                Subject: CN=rhds11.example.com
      
      . . . Output omitted . . .
      
          Certificate:
              Data:
                  Version:  v3
                  Serial Number: 0x66AA3D5
                  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: Friday, September 15, 2023 3:22:33 PM EDT America/New_York
                      Not  After: Tuesday, September 15, 2043 3:22:33 PM 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: 0xABA9C22
                  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, September 19, 2023 3:55:59 PM EDT America/New_York
                      Not  After: Friday, September 19, 2042 3:55:59 PM 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.
      Copy to Clipboard Toggle word wrap
    2. 将新 Server-Cert DS 证书保存到 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-kra.pem
      Copy to Clipboard Toggle word wrap

      其中 Server-Cert-kra.pem 是 Directory Server 实例的新 Server-Cert 证书,它充当 KRA 的 internaldb。

      注意

      RootCA 的签名证书应与以下命令的输出匹配:

      # certutil -L -d /var/lib/pki/rhcs10-RSA-RootCA/alias/ -n "CA Signing Cert - rhcs10-RSA-RootCA" -a
      Copy to Clipboard Toggle word wrap
  4. 远程将新的 Server-Cert 证书复制到 rhds11.example.com。例如:

    # scp /root/.dogtag/pki_rsa_bootstrap/certs_db/Server-Cert-kra.pem root@rhds11.example.com:/etc/dirsrv/slapd-CC-RSA-KRA-LDAP/
    Copy to Clipboard Toggle word wrap

替换临时 DS 证书

rhds11.example.com 上,将临时 DS 证书替换为实际的 DS 证书:

  1. dirsrv 目录的内容保存到备份目录中:

    # cp -r /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/ /etc/dirsrv/save-rsa/slapd-CC-RSA-KRA-LDAP/
    Copy to Clipboard Toggle word wrap
  2. 删除旧的 DS 证书:

    # certutil -D -d /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/ -f /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/pwdfile.txt -n "Server-Cert"
    Copy to Clipboard Toggle word wrap
    # certutil -D -d /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/ -f /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/pwdfile.txt -n "Self-Signed-CA"
    Copy to Clipboard Toggle word wrap
  3. 逐个导入新创建的 DS 证书和 CA 证书。例如:

    # certutil -d /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/ -f /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/pwdfile.txt -A -t "CT,C,C" -n "CA Signing Cert - rhcs10-RSA-RootCA" -i /opt/pki_rsa/rootCA.pem
    Copy to Clipboard Toggle word wrap
    # certutil -d /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/ -f /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/pwdfile.txt -A -t "CT,C,C" -n "CA Signing Cert - rhcs10-RSA-SubCA" -i /opt/pki_rsa/subCA.pem
    Copy to Clipboard Toggle word wrap
    # certutil -d /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/ -f /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/pwdfile.txt -A -t "u,u,u" -n "Server-Cert" -i /etc/dirsrv/slapd-CC-RSA-KRA-LDAP/Server-Cert-kra.pem
    Copy to Clipboard Toggle word wrap
  4. 列出证书:

    # certutil -L -d /etc/dirsrv/slapd-CC-RSA-KRA-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
    Copy to Clipboard Toggle word wrap
  5. 启动 DS :

    # dsctl slapd-CC-RSA-KRA-LDAP start
    Copy to Clipboard Toggle word wrap
  6. 测试以确认 LDAP 服务器已启动并在运行(如果是单独的系统,则在 CA 主机上进行测试):

    # ldapsearch -x -D "cn=Directory Manager" -H ldaps://rhds11.example.com:22636 -b "dc=example,dc=com" -w SECret.123
    Copy to Clipboard Toggle word wrap

    如果在单独的系统上测试,请在 ldapsearch 命令前面包含 CA 证书链,例如:

    # LDAPTLS_CACERT=/opt/pki_rsa/ca-chain.pem ldapsearch -x -D "cn=Directory Manager" -H ldaps://rhds11.example.com:22636 -b "dc=example,dc=com" -w SECret.123
    Copy to Clipboard Toggle word wrap

7.9.2. 安装 KRA 实例

要安装 KRA 请使用单步方法或两步方法。以下流程描述了单步方法。如果要使用两步方法进行安装,请参阅 ] 和 xref:_rootca_two_step[

重要

BEFORE 安装 KRA,如果您打算将 AIA 扩展指向外部 OCSP 实例,而不是 CA 的内部 OCSP,请确保首先按照 第 7.7.4 节 “设置默认 AIA 扩展以指向此 OCSP” 中的步骤操作。

先决条件

流程

  1. 在所选位置(如 /root/pki_rsa)创建一个 KRA 安装文件:

    # cd /root/pki_rsa
    Copy to Clipboard Toggle word wrap
    # vi kra_inst.cfg
    Copy to Clipboard Toggle word wrap
    注意

    除非明确指定,否则系统证书别名将自动命名为 pki_instance_name 的值。为了避免共享 HSM 上的证书别名冲突,请为每个实例创建使用不同的实例名称。

    以下安装文件中指定的值是示例。除了更改 HSM 密码外,还要相应地编辑值,如 ports, directory, nicknames, domains…​

    [DEFAULT]
    pki_instance_name=rhcs10-RSA-KRA
    pki_https_port=28443
    pki_http_port=28080
    
    ### Crypto Token
    pki_hsm_enable=True
    pki_hsm_libfile=/opt/nfast/toolkits/pkcs11/libcknfast.so
    pki_hsm_modulename=nfast
    pki_token_name=NHSM-CONN-XC
    pki_token_password=<YourHSMpassword>
    
    pki_audit_signing_token=NHSM-CONN-XC
    pki_audit_signing_key_algorithm=SHA256withRSA
    pki_audit_signing_key_size=2048
    pki_audit_signing_key_type=rsa
    pki_audit_signing_signing_algorithm=SHA256withRSA
    
    pki_subsystem_token=NHSM-CONN-XC
    pki_subsystem_key_algorithm=SHA256withRSA
    pki_subsystem_signing_algorithm=SHA256withRSA
    pki_subsystem_key_size=2048
    pki_subsystem_key_type=rsa
    
    pki_sslserver_token=NHSM-CONN-XC
    pki_sslserver_key_algorithm=SHA256withRSA
    pki_sslserver_signing_algorithm=SHA256withRSA
    pki_sslserver_key_size=2048
    pki_sslserver_key_type=rsa
    
    ### CA cert chain concatenated in PEM format
    pki_cert_chain_path=/opt/pki_rsa/ca-chain.pem
    
    ### Bootstrap Admin
    pki_admin_password=SECret.123
    pki_admin_key_type=rsa
    pki_admin_key_size=2048
    pki_admin_key_algorithm=SHA256withRSA
    
    ### Bootstrap Admin client dir
    pki_client_admin_cert_p12=/opt/pki_rsa/rhcs10-RSA-KRA/kra_admin_cert.p12
    pki_client_database_dir=/opt/pki_rsa/rhcs10-RSA-KRA/certs_db
    pki_client_database_password=SECret.123
    pki_client_database_purge=False
    pki_client_dir=/opt/pki_rsa/rhcs10-RSA-KRA
    pki_client_pkcs12_password=SECret.123
    
    ### Internal LDAP
    pki_ds_bind_dn=cn=Directory Manager
    pki_ds_ldap_port=22389
    pki_ds_ldaps_port=22636
    pki_ds_password=SECret.123
    pki_ds_remove_data=True
    pki_ds_secure_connection=True
    pki_ds_secure_connection_ca_pem_file=/opt/pki_rsa/ca-chain.pem
    pki_ds_secure_connection_ca_nickname=CA Signing Cert - rhcs10-RSA-SubCA
    
    ### Security Domain
    pki_security_domain_hostname=rhcs10.example.com
    pki_security_domain_https_port=31443
    pki_security_domain_password=SECret.123
    pki_security_domain_user=caadmin
    
    
    [Tomcat]
    pki_ajp_port=28009
    pki_tomcat_server_port=28005
    
    [KRA]
    pki_import_admin_cert=False
    
    pki_storage_token=NHSM-CONN-XC
    pki_storage_key_algorithm=SHA256withRSA
    pki_storage_key_size=2048
    pki_storage_key_type=rsa
    pki_storage_signing_algorithm=SHA256withRSA
    
    pki_transport_token=NHSM-CONN-XC
    pki_transport_key_algorithm=SHA256withRSA
    pki_transport_key_size=2048
    pki_transport_key_type=rsa
    pki_transport_signing_algorithm=SHA256withRSA
    
    pki_admin_nickname=PKI Bootstrap Administrator for RSA-KRA
    pki_admin_name=kraadmin
    pki_admin_uid=kraadmin
    pki_admin_email=kraadmin@example.com
    
    pki_ds_hostname=rhds11.example.com
    pki_ds_base_dn=dc=RSA-KRA
    pki_ds_database=CC-RSA-KRA-LDAP
    pki_share_db=False
    Copy to Clipboard Toggle word wrap
  2. 运行 pkispawn 工具来安装 KRA 子系统:

    # pkispawn -s KRA -f kra_inst.cfg --debug
    Copy to Clipboard Toggle word wrap

    这将在 /var/lib/pki/rhcs10-RSA-KRA 中创建 KRA 实例。

注意

为便于参考,如果您想要使用两步方法安装 KRA:

  1. 首先使用 --skip-configuration 选项运行 pkispawn 工具来安装 RHCS KRA 实例:

    # pkispawn -s KRA -f kra_inst.cfg --skip-configuration --debug
    Copy to Clipboard Toggle word wrap
  2. 在两个安装步骤间自定义配置文件
  3. 运行 pkispawn 工具来配置 KRA:

    # pkispawn -s KRA -f kra_inst.cfg --skip-installation --debug
    Copy to Clipboard Toggle word wrap

验证

  1. 显示已安装 KRA 实例的状态:

    # pki-server status rhcs10-RSA-KRA
    Copy to Clipboard Toggle word wrap

    请注意安全代理、Admin 和 pkiconsole URL。

  2. 验证 KRA 代理网页是否可以访问。
  3. 将 KRA bootstrap 管理员证书导入到 nssdb 中:

    # pki -d /root/.dogtag/pki_rsa_bootstrap/certs_db client-cert-import --pkcs12 /opt/pki_rsa/rhcs10-RSA-KRA/kra_admin_cert.p12 --pkcs12-password SECret.123
    Copy to Clipboard Toggle word wrap
  4. 通过运行 kra-key-request-find 命令验证 KRA 的健全性。它应该显示证书:

    # pki -p 28443 -d /root/.dogtag/pki_rsa_bootstrap/certs_db -n “PKI Bootstrap Administrator for RSA-KRA” kra-key-request-find
    Copy to Clipboard Toggle word wrap
注意

在完成下一小节中详述的设置步骤后,您只能执行实际的密钥归档和恢复测试。

7.9.3. 为 KRA 配置 OAEP 支持

将 KRA 配置为使用 OAEP (Optimal Asymmetric Encryption Padding)密钥传输协议通过编辑 KRA 的 CS.cfg 配置文件来完成。

注意

本节适用于支持 AES 密钥 wrapping/unwrapping 的 HSM,如带有固件 v12.72.1 的 Entrust nShield Connect XC 单元。

前提条件

  • 以 root 用户身份登录 rhcs10.example.com

流程

  1. 停止 KRA:

    # pki-server stop rhcs10-RSA-KRA
    Copy to Clipboard Toggle word wrap
  2. 编辑 /var/lib/pki/rhcs10-RSA-KRA/kra/conf/CS.cfg 配置文件并添加以下三行:

keyWrap.useOAEP=true
kra.legacyPKCS12=false
kra.nonLegacyAlg=AES/None/PKCS5Padding/Kwp/256

  1. 启动 KRA:

    # pki-server start rhcs10-RSA-KRA
    Copy to Clipboard Toggle word wrap
  2. 重启 SubCA:

    # pki-server restart rhcs10-RSA-SubCA
    Copy to Clipboard Toggle word wrap

7.9.4. 创建 KRA 角色用户

7.9.5. 测试密钥归档

本例演示了没有任何 pki 角色的普通用户如何创建证书注册请求,并使其自动发布(= 自签名 CMC 注册),同时让私钥由 KRA 归档。

重要

先决条件配置

如果您之前还没有这样做,请按照 第 7.8.4.3 节 “测试 CMC 共享令牌” 中的步骤为您的测试用户设置共享 secret (本例中为 FooUser123)。

流程

此流程提供常规(非pki-role)用户(如 FooUser123)要执行的步骤,以便自行执行自签名 CMC 证书注册。这可以在任何 FooUser123 的主目录中 完成,例如 /home/FooUser123/certs_db

  1. 如果客户端 nssdb 不存在,请创建一个:

    $ pki -d /home/FooUser123/certs_db -c SECret.123 client-init
    Copy to Clipboard Toggle word wrap
  2. 使用 KRA 传输证书创建一个 CRMF 请求:

    1. 在 SubCA 的 EE 页面(本例中为 0x555251b)中找到 KRA 传输证书序列号。
      另外,如果您知道证书的通用名称,您也可以找到其序列号,例如:

      # pki -p 31443 ca-cert-find --name "DRM Transport Certificate"
      ---------------
      1 entries found
      ---------------
       Serial Number: 0x555251b
       Subject DN: CN=DRM Transport Certificate,OU=rhcs10-RSA-KRA,O=Example-rhcs10-RSA-KRA
       Status: VALID
      ...
      ----------------------------
      Number of entries returned 1
      ----------------------------
      Copy to Clipboard Toggle word wrap
    2. 使用其序列号导出 KRA 传输证书:

      # pki -d /home/FooUser123/certs_db -c SECret.123 -p 31443 ca-cert-export 0x555251b --output-file /home/FooUser123/certs_db/kra_transport.txt
      Copy to Clipboard Toggle word wrap
    3. 使用传输证书创建 CRMF 请求:

      # CRMFPopClient -d /home/FooUser123/certs_db -p SECret.123 -n "cn=FooUser123, uid=FooUser123" -q POP_SUCCESS -b /home/FooUser123/certs_db/kra_transport.txt -w "AES KeyWrap/Wrapped" -y -o /home/FooUser123/certs_db/crmf.req -oaep
      
      CryptoUtil: generateRSAKeyPair: calling kg.setKeyPairUsages
      Keypair private key id: 56906e65ef43a2e756908726758e9061d8d7ee9c
      CRMFPopClient: use_shared_secret true. Generating SubjectKeyIdentifier extension.
      Storing CRMF request into /home/FooUser123/certs_db/crmf.req
      Storing CRMF request key id into /home/FooUser123/certs_db/crmf.req.keyId
      Copy to Clipboard Toggle word wrap
  3. 生成 CMC 请求:

    1. 使用您在上一步中获取的 CRMF 请求和私钥 ID 创建 CMCRequest 配置文件。例如:

      # vi /home/FooUser123/certs_db/cmc-crmf-self.cfg
      Copy to Clipboard Toggle word wrap
      ### 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.
      input=/home/FooUser123/certs_db/crmf.req
      
      ### output: full path for the CMC request in binary format
      output=/home/FooUser123/certs_db/cmc.self.req
      
      ### tokenname: name of the token where agent signing cert can be found (default is internal)
      tokenname=internal
      request.useSharedSecret=true
      
      ### nickname: nickname for the agent certificate which will be used to sign the CMC full request.
      #nickname=
      
      ### dbdir: directory for cert8.db, key3.db and secmod.db
      dbdir=/home/FooUser123/certs_db
      
      ### password: password for cert8.db which stores the agent certificate
      password=SECret.123
      
      ### format: request format, either pkcs10 or crmf
      format=crmf
      
      ### identityProofV2.enable: if true, then the request will contain this control. Otherwise, false.
      ### Note that if both identityProof and identityProofV2 are enabled,
      ### identityProofV2 takes precedence; Only one of them can be active at a time
      ### Supported hashAlg are:
      ### SHA-256, SHA-384, and SHA-512
      ### Supported macAlg are:
      ### SHA-256-HMAC, SHA-384-HMAC, and SHA-512-HMAC
      identityProofV2.enable=true
      identityProofV2.hashAlg=SHA-512
      identityProofV2.macAlg=SHA-256-HMAC
      
      ### identityProofV2.sharedSecret: Shared Secret
      witness.sharedSecret=secretShrTokFooUser123
      
      popLinkWitnessV2.enable=true
      popLinkWitnessV2.keyGenAlg=SHA-256
      popLinkWitnessV2.macAlg=SHA-256-HMAC
      
      request.privKeyId=<output from PKCS10Client|CRMFPopClient xxx.priv>
      
      ### identification works with identityProofV2
      identification.enable=true
      identification=FooUser123
      Copy to Clipboard Toggle word wrap
    2. 使用 CMCRequest 命令生成请求:

      # CMCRequest /home/FooUser123/certs_db/cmc-crmf-self.cfg
      
      cert/key prefix =
      path = /home/FooUser123/certs_db
      CryptoManger initialized
      token internal logged in...
      got request privKeyId: 56906e65ef43a2e756908726758e9061d8d7ee9c
      got private key
      createPKIData: begins
      createPopLinkWitnessV2Attr: begins
      createPopLinkWitnessV2Attr: keyGenAlg=SHA-256; macAlg=SHA-256-HMAC
      createPopLinkWitnessV2Attr: Successfully created id_cmc_idPOPLinkRandom control. bpid = 1
      createPopLinkWitnessV2Attr: Successfully created PopLinkWitnessV2 control.
      createPopLinkWitnessV2Attr: returning...
      
      k=0
      createPKIData:  format: crmf
      CryptoUtil: getSKIExtensionFromCertTemplate: SKIoid == jssOID
      createPKIData:  SubjectKeyIdentifier extension found in use_shared_secret request
      createPKIData: popLinkWitnessV2 enabled. reconstructing crmf
      createNewPOP: begins
      createNewPOP: about to create POPOSigningKey
      createNewPOP: creating and returning newPopOfSigningKey
      createPKIData: new CRMF b64encode completes.
      -----BEGIN CERTIFICATE REQUEST-----
      MIIIsDCCCKwwggeQAgEBMIIBfYABAqUzMDExGjAYBgoJkiaJk/IsZAEBEwpGb29Vc2VyMTIzMRMw
      
      . . . Output omitted . . .
      
      -----END CERTIFICATE REQUEST-----
      
      identification control: identification =FooUser123
      Successfully create identification control. bpid = 1
      
      CMCRequest: addIdentityProofV2Attr: hashAlg=SHA-512; macAlg=SHA-256-HMAC
      Identity Proof V2 control:
         Value: -50 -36 103 -38 70 85 70 91 -71 96 -121 100 -127 50 -63 -57 123 -30 115 58 -55 -34 -22 104 90 -20 48 46 80 -85 64 68
      Successfully create identityProofV2 control. bpid = 2
      
      useSharedSecret is true...
      signData for useSharedSecret begins: begins:
      createSignedData: begins
      getSigningAlgFromPrivate: begins.
      getSigningAlgFromPrivate: found signingKeyType=RSA
      getSigningAlgFromPrivate: using SignatureAlgorithm: RSASignatureWithSHA256Digest
      createSignedData: digest created for pkidata
      createSignedData: digest algorithm =RSASignatureWithSHA256Digest
      getCMCBlob: begins
      getCMCBlob: generating signed data
      
      The CMC enrollment request in base-64 encoded format:
      MIILlAYJKoZIhvcNAQcCoIILhTCCC4ECAQMxDzANBglghkgBZQMEAgEFADCCCdgGCCsGAQUFBwwC
      
      . . . Output omitted . . .
      
      The CMC enrollment request in binary format is stored in /home/FooUser123/certs_db/cmc.self.req
      Copy to Clipboard Toggle word wrap
  4. 提交 CMC 请求:

    1. 创建 HttpClient 配置文件。例如:

      # vim /home/FooUser123/certs_db/HttpClient-cmc-crmf.self.cfg
      Copy to Clipboard Toggle word wrap
      ### 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=/home/FooUser123/certs_db/cmc.self.req
      
      ### output: full path for the response in binary format
      output=/home/FooUser123/certs_db/cmc.self.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=/home/FooUser123/certs_db
      
      ### clientmode: true for client authentication, false for no client authentication
      ### This parameter will be ignored if secure=false
      clientmode=false
      
      ### 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=
      
      ### servlet: servlet name
      servlet=/ca/ee/ca/profileSubmitCMCFull?profileId=caFullCMCSharedTokenCert
      Copy to Clipboard Toggle word wrap
    2. 使用 HttpClient 命令提交请求:

      # HttpClient /home/FooUser123/certs_db/HttpClient-cmc-crmf.self.cfg
      
      Total number of bytes read = 2968
      after SSLSocket created, thread token is NSS FIPS 140-2 User Private Key
      handshake happened
      writing to socket
      
      #Response Headers begin
      HTTP/1.1 200
      Content-Type: application/pkcs7-mime
      Content-Length: 4348
      Date: Thu, 08 Sep 2022 20:51:44 GMT
      Connection: close
      #end
      
      Total number of bytes read = 4348
      MIIQ+AYJKoZIhvcNAQcCoIIQ6TCCEOUCAQMxDzANBglghkgBZQMEAgEFADAxBggrBgEFBQcMA6Al
      
      . . . Output omitted . . .
      
      The response in binary format is stored in /home/FooUser123/certs_db/cmc.self.Resp
      Copy to Clipboard Toggle word wrap
  5. 使用 CMCResponse 命令处理响应:

    # CMCResponse -d /home/FooUser123/certs_db -i /home/FooUser123/certs_db/cmc.self.Resp
    
    Certificates:
        Certificate:
            Data:
                Version:  v3
                Serial Number: 0x98D0212
                Signature Algorithm: SHA256withRSA - 1.2.840.113549.1.1.11
                Issuer: CN=CA Signing Certificate,OU=rhcs10-RSA-SubCA,O=Example-rhcs10-RSA-RootCA
                Validity:
                    Not Before: Thursday, September 8, 2022 4:51:44 PM EDT America/New_York
                    Not  After: Tuesday, March 7, 2023 4:51:44 PM EST America/New_York
                Subject: UID=FooUser123,DC=example,DC=com
                Subject Public Key Info:
                    Algorithm: RSA - 1.2.840.113549.1.1.1
                    Public Key:
                        Exponent: 65537
                        Public Key Modulus: (2048 bits) :
                            BB:F3:C6:66:AC:9E:39:02:59:B8:E7:5A:6D:9E:29:8C:
    
    . . . 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.
    Copy to Clipboard Toggle word wrap

验证:

  • 要验证 KRA UI 的健全性,请访问 KRA 代理页面 选择请求类型 Show key archival 请求 以及 Show completed 的请求。这应该会显示 CN=FooUser123, UID=FooUser123 的归档密钥信息。

7.9.6. 测试密钥恢复

通过以下步骤测试密钥恢复过程:

  1. 作为 KRA 代理,进入浏览器中的 KRA 代理服务页面,然后点 Recover Keys 链接。
  2. 选择 证书 复选框以便按证书搜索密钥:

    1. 解析之前的响应文件,以 base64 格式显示叶证书,例如:

      # CMCResponse -d /home/FooUser123/certs_db -i /home/FooUser123/certs_db/cmc.self.Resp -v
      Copy to Clipboard Toggle word wrap
    2. 将 base64 编码的叶证书复制并粘贴到文本字段中(例如 cert0 :确保证书的"Subject"具有 UID=FooUser123,DC=example,DC=com),验证 显示 密钥。
  3. Recover。确保选择了 Async Recovery 复选框,以便在恢复持续时允许浏览器会话关闭。

    注意

    异步恢复是执行密钥恢复的默认方法。不再支持同步密钥恢复。

  4. Recover。根据代理方案,指定数量的代理必须授权此密钥恢复。使代理搜索密钥以恢复,然后批准开始的恢复。
  5. 当所有代理都授权恢复后,选择代理页面左侧的 List Requests,然后选择 Request type show key recovery requests and Request status show all requests
  6. 点与批准的恢复请求对应的请求号,根据要求输入 PKCSautomationhub 密码两次,然后点 Retrieve PKCSmtc
  7. 弹出一个对话框。单击 Save File,以下载私钥证书所有者的 PKCSautomationhub 文件。
  8. 收到 PKCSautomationhub 文件后,证书/密钥所有者可以将密钥恢复到其 Firefox nssdb 中。例如:

    # pk12util -d ~/.mozilla/firefox/’1234gggg.Default User’ -n "FooUser123 cert" -i getAsyncPk12
    Copy to Clipboard Toggle word wrap
  9. 现在,您可以再次使用该证书。

7.9.7. 增加 KRA pkiconsole 超时

  1. 停止 KRA:

    # pki-server stop rhcs10-RSA-KRA
    Copy to Clipboard Toggle word wrap
  2. 通过编辑 /var/lib/pki/rhcs10-RSA-KRA/conf/server.xml 文件来增加超时周期:

    <Connector name="Secure" port="28443" …
    connectionTimeout="3000000"
    Copy to Clipboard Toggle word wrap
  3. 然后重启 KRA:

    # pki-server start rhcs10-RSA-KRA
    Copy to Clipboard Toggle word wrap

7.9.8. 使用客户端身份验证登录到 KRA pkiconsole

  1. 使用 authType=sslclientauth 配置 KRA,并通过以下 第 7.13.6 节 “使用客户端身份验证配置 pkiconsole 登录” 导入角色用户证书。
  2. 使用角色用户的客户端身份验证证书登录到 pkiconsole:

    # pkiconsole -d <home .redhat-idm-console dir> -n <client cert> https://rhcs10.example.com:28443/kra
    Copy to Clipboard Toggle word wrap

    然后从列表中选择角色用户证书别名,如 KRA adminV。登录到控制台应该可以成功。

7.9.9. 安装后

如果要安装其他 RHCS 实例,请继续下一小节。完成所有需要的 RHCS 实例安装后,请访问 第 7.13 节 “安装后” 以完成额外的设置。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat