7.10. 创建并配置 TKS 实例


本节描述了针对 SubCA 安装和配置 TKS 实例。
TKS 系统证书将由 SubCA 发布,TKS 将加入 SubCA 安全域。
在本例中,TKS 安装在 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.10.1. 替换临时 DS 证书(TKS)

在安装 TKS 之前,我们为 TKS 的目录服务器发布官方 SSL 服务器证书来替换临时引导。为此,我们首先要为目录服务器证书创建一个证书签名请求(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-TKS-LDAP stop
    Copy to Clipboard Toggle word wrap
  2. 使用 certutil 工具生成 CSR:

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

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

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

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

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

    # scp /etc/dirsrv/slapd-CC-RSA-TKS-LDAP/Server-Cert-tks.csr root@rhcs10.example.com:/root/.dogtag/pki_rsa_bootstrap/certs_db/Server-Cert-tks.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-tks_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-tks.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-tks_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-tks_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-tks_pkcs10.req
      Copy to Clipboard Toggle word wrap
  2. 提交 CMC 请求:

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

      # vim /root/.dogtag/pki_rsa_bootstrap/certs_db/HttpClient_dirsrv-tks.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-tks_pkcs10.req
      
      ### output: full path for the response in binary format
      output=/root/.dogtag/pki_rsa_bootstrap/certs_db/cmc.dirsrv-tks_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-tks.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-tks_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-tks_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-TKS,O=Example-rhcs10-RSA-TKS
                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-TKS
                  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-TKS,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-tks.pem
      Copy to Clipboard Toggle word wrap

      其中 Server-Cert-tks.pem 是 Directory Server 实例的新 Server-Cert 证书,充当 TKS 的 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-tks.pem root@rhds11.example.com:/etc/dirsrv/slapd-CC-RSA-TKS-LDAP/
    Copy to Clipboard Toggle word wrap

替换临时 DS 证书

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

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

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

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

    # certutil -d /etc/dirsrv/slapd-CC-RSA-TKS-LDAP/ -f /etc/dirsrv/slapd-CC-RSA-TKS-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-TKS-LDAP/ -f /etc/dirsrv/slapd-CC-RSA-TKS-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-TKS-LDAP/ -f /etc/dirsrv/slapd-CC-RSA-TKS-LDAP/pwdfile.txt -A -t "u,u,u" -n "Server-Cert" -i /etc/dirsrv/slapd-CC-RSA-TKS-LDAP/Server-Cert-tks.pem
    Copy to Clipboard Toggle word wrap
  4. 列出证书:

    # certutil -L -d /etc/dirsrv/slapd-CC-RSA-TKS-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-TKS-LDAP start
    Copy to Clipboard Toggle word wrap
  6. 测试以确认 LDAP 服务器已启动并在运行(如果是单独的系统,则在 CA 主机上进行测试):

    # ldapsearch -x -D "cn=Directory Manager" -H ldaps://rhds11.example.com:16636 -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:16636 -b "dc=example,dc=com" -w SECret.123
    Copy to Clipboard Toggle word wrap

7.10.2. 安装 TKS 实例

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

重要

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

先决条件

流程

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

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

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

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

    [DEFAULT]
    pki_instance_name=rhcs10-RSA-TKS
    pki_https_port=24443
    pki_http_port=24080
    
    ### 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-TKS/tks_admin_cert.p12
    pki_client_database_dir=/opt/pki_rsa/rhcs10-RSA-TKS/certs_db
    pki_client_database_password=SECret.123
    pki_client_database_purge=False
    pki_client_dir=/opt/pki_rsa/rhcs10-RSA-TKS
    pki_client_pkcs12_password=SECret.123
    
    ### Internal LDAP
    pki_ds_bind_dn=cn=Directory Manager
    pki_ds_ldap_port=16389
    pki_ds_ldaps_port=16636
    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=14009
    pki_tomcat_server_port=14005
    
    
    [TKS]
    pki_import_admin_cert=False
    
    pki_admin_nickname=PKI Bootstrap Administrator for RSA-TKS
    pki_admin_name=tksadmin
    pki_admin_uid=tksadmin
    pki_admin_email=tksadmin@example.com
    
    pki_ds_hostname=rhds11.example.com
    pki_ds_base_dn=dc=RSA-TKS
    pki_ds_database=CC-RSA-TKS-LDAP
    pki_share_db=False
    Copy to Clipboard Toggle word wrap
  2. 运行 pkispawn 工具来安装 TKS 子系统:

    # pkispawn -s TKS -f tks_inst.cfg --debug
    Copy to Clipboard Toggle word wrap

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

注意

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

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

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

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

验证

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

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

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

7.10.3. 为 TKS 配置 OAEP 支持

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

注意

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

前提条件

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

流程

  1. 停止 TKS:

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

keyWrap.useOAEP=true

  1. 启动 TKS:

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

7.10.4. 创建 TKS 角色用户

7.10.5. 安装后

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

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat