注册 CA 证书 - Amazon IoT Core
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

注册 CA 证书

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

注意

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

您可以在 DEFAULT 模式或 SNI_ONLY 模式下注册 CA 证书。CA 可以一对一 Amazon Web Services 账户 地在DEFAULT模式下注册 Amazon Web Services 区域。一个 CA 可以在同一个SNI_ONLY模式下通过多个 Amazon Web Services 账户 CA 进行注册 Amazon Web Services 区域。有关 CA 证书模式的更多信息,请参阅 certificateMode

注意

我们建议您在 SNI_ONLY 模式下注册 CA。您无需提供验证证书或访问私钥的权限,并且可以在同一个证书 Amazon Web Services 账户 中多次注册 CA Amazon Web Services 区域。

在 SNI_ONLY 模式下注册 CA 证书(CLI)- 建议

先决条件

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

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

  • OpenSSL v1.1.1i 或更高版本

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

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

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

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

    此步骤将激活 CA 证书。

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

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

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

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

先决条件

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

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

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

  • OpenSSL v1.1.1i 或更高版本

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

    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 证书 Amazon IoT。将 CA 证书文件名和私有密钥验证证书文件名传递给 register-ca-certificate 命令,如下所示:有关更多信息,请参阅 Amazon CLI 命令参考 中的 register-ca-certificate

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

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

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

    此步骤将激活 CA 证书。

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

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

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