管理 CA 证书 - AWS IoT Core

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

管理 CA 证书

本节介绍管理您自己的证书颁发机构 (CA) 证书的常见任务。

您可以向注册您的证书颁发机构 (CA) AWS IoT 如果你使用的是由 CA 签名的客户端证书 AWS IoT 认不出来。

如果你想让客户自动注册他们的客户证书 AWS IoT 当他们首次连接时,必须向注册签署客户端证书的 CA AWS IoT。 否则,您无需注册签署客户端证书的 CA 证书。

注意

DEFAULT 模式下,一个 CA 证书只能由一个区域中的一个账户注册。在 SNI_ONLY 模式下,一个 CA 证书可以由一个区域中的多个账户注册。

创建 CA 证书

如果您没有 CA 证书,则可以使用 Op SSL en v1.1.1i 工具创建一个。

注意

您无法在中执行此过程 AWS IoT console。

使用 Ope n SSL v1.1.1 i 工具创建 CA 证书
  1. 生成密钥对。

    openssl genrsa -out root_CA_key_filename.key 2048
  2. 使用密钥对中的私有密钥生成 CA 证书。

    openssl req -x509 -new -nodes \ -key root_CA_key_filename.key \ -sha256 -days 1024 \ -out root_CA_cert_filename.pem

注册 CA 证书

这些程序描述了如何注册来自非亚马逊 CA 的证书颁发机构 (CA) 的证书。 AWS IoT Core 使用 CA 证书验证证书的所有权。要使用由非亚马逊 CA 签发的 CA 签名的设备证书,您必须向注册 CA 证书 AWS IoT Core 以便它可以验证设备证书的所有权。

注册 CA 证书(控制台)

注意

若要在控制台中注册 CA 证书,请在控制台中的 Register CA certificate(注册 CA 证书)处开始注册。您可以在多账户模式下注册您的 CA,而无需提供验证证书或访问私有密钥的权限。一个 CA 可以通过多个账户在多账户模式下注册 AWS 账户 在同一个地方 AWS 区域。 您可以通过提供验证证书和 CA 私钥的所有权证明,在单账户模式下注册您的 CA。

注册 CA 证书 (CLI)

您可以在 DEFAULT 模式或 SNI_ONLY 模式下注册 CA 证书。一个 CA 可以在DEFAULT模式下通过一个注册 AWS 账户 合而为一 AWS 区域。 一个 CA 可以通过多个 CA 在SNI_ONLY模式下注册 AWS 账户 在同一个地方 AWS 区域。 有关 CA 证书模式的更多信息,请参阅certificateMode

注意

我们建议您在 SNI_ONLY 模式下注册 CA。您无需提供验证证书或访问私钥的权限,并且可以通过多个方式注册 CA AWS 账户 在同一个地方 AWS 区域.

在 SNI _ ONLY 模式下注册 CA 证书 (CLI)-推荐

先决条件

继续操作之前,请确保电脑满足以下条件:

  • 根 CA 的证书文件(在以下示例中引用为 root_CA_cert_filename.pem

  • 打开 SSL v1.1.1i 或更高版本

要在SNI_ONLY模式下注册 CA 证书,请使用 AWS CLI
  1. 向注册 CA 证书 AWS IoT。 使用register-ca-certificate命令输入 CA 证书文件名。有关更多信息,请参阅register-ca-certificate中的 AWS CLI 命令参考

    aws iot register-ca-certificate \ --ca-certificate file://root_CA_cert_filename.pem \ --certificate-mode SNI_ONLY

    如果成功,此命令将返回 certificateId.

  2. 此时,CA 证书已注册到 AWS IoT 但处于非活动状态。CA 证书必须处于活跃状态,然后您才能注册由其签发的任何客户端证书。

    此步骤将激活 CA 证书。

    要激活 CA 证书,请使用 update-certificate 命令,如下所示。有关更多信息,请参阅《更新证书》中的 AWS CLI 命令参考

    aws iot update-ca-certificate \ --certificate-id certificateId \ --new-status ACTIVE

要查看 CA 证书的状态,请使用 describe-ca-certificate 命令。有关更多信息,请参阅describe-ca-certificate中的 AWS CLI 命令参考

DEFAULT模式 (CLI) 下注册 CA 证书

先决条件

继续操作之前,请确保电脑满足以下条件:

  • 根 CA 的证书文件(在以下示例中引用为 root_CA_cert_filename.pem

  • 根 CA 证书的私有密钥文件(在以下示例中引用为 root_CA_key_filename.key

  • 打开 SSL v1.1.1i 或更高版本

要在DEFAULT模式下注册 CA 证书,请使用 AWS CLI
  1. 要从中获取注册码 AWS IoT,使用get-registration-code。保存返回的 registrationCode,将其用作私有密钥验证证书的 Common Name。有关更多信息,请参阅get-registration-code中的 AWS CLI 命令参考

    aws iot get-registration-code
  2. 为私有密钥验证证书生成密钥对:

    openssl genrsa -out verification_cert_key_filename.key 2048
  3. 为私钥验证证书创建证书签名请求 (CSR)。将证书的 Common Name 字段设置为 get-registration-code 返回的 registrationCode

    openssl req -new \ -key verification_cert_key_filename.key \ -out verification_cert_csr_filename.csr

    将提示您输入一些信息,包括证书的Common Name

    You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]: State or Province Name (full name) []: Locality Name (for example, city) []: Organization Name (for example, company) []: Organizational Unit Name (for example, section) []: Common Name (e.g. server FQDN or YOUR name) []:your_registration_code Email Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:
  4. 使用CSR创建私钥验证证书:

    openssl x509 -req \ -in verification_cert_csr_filename.csr \ -CA root_CA_cert_filename.pem \ -CAkey root_CA_key_filename.key \ -CAcreateserial \ -out verification_cert_filename.pem \ -days 500 -sha256
  5. 向注册 CA 证书 AWS IoT。 将 CA 证书文件名和私钥验证证书文件名传递给register-ca-certificate命令,如下所示。有关更多信息,请参阅register-ca-certificate中的 AWS CLI 命令参考

    aws iot register-ca-certificate \ --ca-certificate file://root_CA_cert_filename.pem \ --verification-cert file://verification_cert_filename.pem

    此命令返回 certificateId,如果成功的话。

  6. 此时,CA 证书已注册到 AWS IoT 但未激活。CA 证书必须处于活跃状态,然后您才能注册由其签发的任何客户端证书。

    此步骤将激活 CA 证书。

    要激活 CA 证书,请使用 update-certificate 命令,如下所示。有关更多信息,请参阅《更新证书》中的 AWS CLI 命令参考

    aws iot update-ca-certificate \ --certificate-id certificateId \ --new-status ACTIVE

要查看 CA 证书的状态,请使用 describe-ca-certificate 命令。有关更多信息,请参阅describe-ca-certificate中的 AWS CLI 命令参考

创建 CA 验证证书以在控制台中注册 CA 证书

注意

此过程仅在您注册来自的 CA 证书时使用 AWS IoT console。

如果你不是从这里开始这个程序 AWS IoT 控制台,在控制台的 “注册 CA 证书” 中启动 CA 证书注册过程。

继续操作之前,请确保同一台电脑满足以下条件:

  • 根 CA 的证书文件(在以下示例中引用为 root_CA_cert_filename.pem

  • 根 CA 证书的私有密钥文件(在以下示例中引用为 root_CA_key_filename.key

  • 打开 SSL v1.1.1i 或更高版本

使用命令行界面创建 CA 验证证书,以在控制台中注册 CA 证书
  1. verification_cert_key_filename.key 替换为要创建的验证证书密钥文件的文件名(例如 verification_cert.key)。然后运行此命令,为私有密钥验证证书生成密钥对:

    openssl genrsa -out verification_cert_key_filename.key 2048
  2. verification_cert_key_filename.key 替换为在步骤 1 中创建的密钥文件的名称。

    verification_cert_csr_filename.csr替换为要创建的证书签名请求 (CSR) 文件的名称。例如,verification_cert.csr

    运行此命令来创建CSR文件。

    openssl req -new \ -key verification_cert_key_filename.key \ -out verification_cert_csr_filename.csr

    该命令会提示您输入其他信息(稍后说明)。

  3. 在 AWS IoT 控制台的 “验证证书” 容器中,复制注册码。

  4. openssl 命令提示您输入的信息显示在以下示例中。除了 Common Name 字段,您可以在其它字段中输入自己的值或将其留空。

    Common Name 字段中,粘贴您在上一步骤中复制的注册码。

    You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]: State or Province Name (full name) []: Locality Name (for example, city) []: Organization Name (for example, company) []: Organizational Unit Name (for example, section) []: Common Name (e.g. server FQDN or YOUR name) []:your_registration_code Email Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:

    完成后,该命令将创建该CSR文件。

  5. verification_cert_csr_filename.csr 替换为在上一步骤中使用的 verification_cert_csr_filename.csr

    root_CA_cert_filename.pem 替换为要注册的 CA 证书的文件名。

    root_CA_key_filename.key 替换为 CA 证书的私有密钥文件的文件名。

    verification_cert_filename.pem 替换为要创建的验证证书的文件名。例如,verification_cert.pem

    openssl x509 -req \ -in verification_cert_csr_filename.csr \ -CA root_CA_cert_filename.pem \ -CAkey root_CA_key_filename.key \ -CAcreateserial \ -out verification_cert_filename.pem \ -days 500 -sha256
  6. O SSL pen 命令完成后,您应该准备好这些文件以备返回控制台时使用。

    • 您的 CA 证书文件(上一条命令中使用的 root_CA_cert_filename.pem

    • 您在上一步中创建的验证证书 (verification_cert_filename.pem 在前面的命令中使用)

停用 CA 证书

启用证书颁发机构 (CA) 证书进行自动客户端证书注册后, AWS IoT 检查 CA 证书以确保 CA 是ACTIVE。如果 CA 证书是INACTIVE, AWS IoT 不允许注册客户端证书。

通过将 CA 证书设置为 INACTIVE,可防止该 CA 颁发的任何新客户端证书自动注册。

注意

除非您明确吊销由受损的 CA 证书签发的每个已注册客户端证书,否则所有此类证书均将继续工作。

停用 CA 证书(控制台)

要停用 CA 证书,请使用 AWS IoT Console
  1. 登录 AWS Management Console 然后打开 AWS IoT 控制台

  2. 在左侧导航窗格中,选择 “安全”,选择CAs

  3. 在证书颁发机构列表中,找到要停用的证书颁发机构,然后选择省略号图标以打开选项菜单。

  4. 在选项菜单上,选择停用

证书颁发机构应在列表中显示为停用

注意

这些区域有: AWS IoT 控制台不提供列出由您停用的 CA 签署的证书的方法。对于 AWS CLI 列出这些证书的选项,请参阅停用 CA 证书 () CLI

停用 CA 证书 () CLI

这些区域有: AWS CLI 提供了停用 CA 证书的update-ca-certificate命令。

aws iot update-ca-certificate \ --certificate-id certificateId \ --new-status INACTIVE

使用 list-certificates-by-ca 命令获取已由指定 CA 签名的所有已注册客户端证书的列表。对于由指定 CA 证书签名的每个客户端证书,请使用 update-certificate 命令吊销该客户端证书以避免使用它。

使用 describe-ca-certificate 命令查看 CA 证书的状态。