Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

4.14. 使用共享系统证书

共享系统证书存储允许 NSS、GnuTLS、OpenSSL 和 Java 共享用于检索系统证书定位符和黑色列表信息的默认源。默认情况下,信任存储包含 Mozilla CA 列表,包括正和负信任。系统允许更新核心 Mozilla CA 列表或选择其他证书列表。

4.14.1. 使用系统范围的信任存储

在 Red Hat Enterprise Linux 7 中,整合的系统范围的信任存储位于 /etc/pki/ca-trust//usr/share/pki/ca-trust-source/ 目录中。对 /usr/share/pki/ca-trust-source/ 中信任设置的优先级的处理低于/etc/pki/ca-trust/ 中的设置。
证书文件根据它们所安装到的子目录处理:
  • /usr/share/pki/ca-trust-source/anchors//etc/pki/ca-trust/source/anchors/ - 用于信任锚。请参阅 第 4.5.6 节 “了解信任 Anchors”
  • /usr/share/pki/ca-trust-source/blacklist//etc/pki/ca-trust/source/blacklist/ - 用于不受信任的证书。
  • /usr/share/pki/ca-trust-source//etc/pki/ca-trust/source/ - 用于扩展 BEGIN TRUSTED 文件格式的证书。

4.14.2. 添加新证书

要将简单 PEM 或 DER 文件格式的证书添加到系统上信任的 CA 列表中,请将证书文件复制到 /usr/share/pki/ca-trust-source/anchors//etc/pki/ca-trust/source/anchors/ 目录中。要更新系统范围的信任存储配置,请使用 update-ca-trust 命令,例如:
# cp ~/certificate-trust-examples/Cert-trust-test-ca.pem /usr/share/pki/ca-trust-source/anchors/
# update-ca-trust
注意
虽然 Firefox 浏览器可以使用添加的证书而无需执行 update-ca-trust,但建议在 CA 更改后运行 update-ca-trust。另请注意,浏览器,如 Firefox、Epiphany 或 Chromium、缓存文件,您可能需要清除浏览器的缓存或重新启动浏览器来加载当前的系统证书配置。

4.14.3. 管理受信任的系统证书

要列出、提取、添加、删除或修改信任锚,请使用 trust 命令。要查看这个命令的内置帮助信息,请不要输入任何参数,或使用 --help 指令:
$ trust
usage: trust command <args>...

Common trust commands are:
  list             List trust or certificates
  extract          Extract certificates and trust
  extract-compat   Extract trust compatibility bundles
  anchor           Add, remove, change trust anchors
  dump             Dump trust objects in internal format

See 'trust <command> --help' for more information
要列出所有系统信任锚和证书,请使用 trust list 命令:
$ trust list
pkcs11:id=%d2%87%b4%e3%df%37%27%93%55%f6%56%ea%81%e5%36%cc%8c%1e%3f%bd;type=cert
    type: certificate
    label: ACCVRAIZ1
    trust: anchor
    category: authority

pkcs11:id=%a6%b3%e1%2b%2b%49%b6%d7%73%a1%aa%94%f5%01%e7%73%65%4c%ac%50;type=cert
    type: certificate
    label: ACEDICOM Root
    trust: anchor
    category: authority
...
[output has been truncated]
trust 命令的所有子命令都提供了详细的内置帮助,例如。
$ trust list --help
usage: trust list --filter=<what>

  --filter=<what>     filter of what to export
                        ca-anchors        certificate anchors
                        blacklist         blacklisted certificates
                        trust-policy      anchors and blacklist (default)
                        certificates      all certificates
                        pkcs11:object=xx  a PKCS#11 URI
  --purpose=<usage>   limit to certificates usable for the purpose
                        server-auth       for authenticating servers
                        client-auth       for authenticating clients
                        email             for email protection
                        code-signing      for authenticating signed code
                        1.2.3.4.5...      an arbitrary object id
  -v, --verbose       show verbose debug output
  -q, --quiet         suppress command output
要将信任锚存储在系统范围的信任存储中,请使用 trust anchor 子命令,并指定 path.to a certificate,例如:
# trust anchor path.to/certificate.crt
要删除证书,请使用 path. 到 证书或证书的 ID:
# trust anchor --remove path.to/certificate.crt
# trust anchor --remove "pkcs11:id=%AA%BB%CC%DD%EE;type=cert"

4.14.4. 其它资源

如需更多信息,请参阅以下手册页:
  • update-ca-trust(8)
  • trust(1)