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

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

注册 CA 证书

这些程序说明如何注册来自 Amazon CA 以外的证书颁发机构(CA)的证书。 Amazon IoT Core使用 CA 证书来验证证书的所有权。要使用由非 Amazon CA 的 CA 签署的设备证书,您必须向注册 CA 证书,Amazon IoT Core以便设备证书的所有权。

注意

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

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

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

先决条件

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

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

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

  • OpenSSL v1.1.1i 或更高版本

DEFAULT 模式下使用 Amazon CLI 注册 CA 证书
  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. 在 Amazon IoT 中注册 CA 证书。将 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

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

先决条件

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

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

  • OpenSSL v1.1.1i 或更高版本

SNI_ONLY 模式下使用 Amazon CLI 注册 CA 证书
  1. 在 Amazon IoT 中注册 CA 证书。使用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

    如果成功,该命令将返回certific ateId

  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