本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
注册 CA 证书
这些程序说明如何注册来自 Amazon CA 以外的证书颁发机构(CA)的证书。 Amazon IoT Core使用 CA 证书来验证证书的所有权。要使用由非 Amazon CA 的 CA 签署的设备证书,您必须向注册 CA 证书,Amazon IoT Core以便设备证书的所有权。
注意
若要在控制台中注册 CA 证书,请在控制台中的 Register CA certificate
您可以在 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 证书
-
要从中获取注册代码Amazon IoT,请使用get-registration-code。保存返回的
registrationCode,将其用作私有密钥验证证书的Common Name。有关更多信息,请参阅《Amazon CLI 命令参考》中的 get-registration-code。 aws iot get-registration-code -
为私有密钥验证证书生成密钥对:
openssl genrsa -outverification_cert_key_filename.key2048 -
为私有密钥验证证书创建证书签名请求 (CSR)。将证书的
Common Name字段设置为 get-registration-code 返回的registrationCode。openssl req -new \ -keyverification_cert_key_filename.key\ -outverification_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_codeEmail Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: -
使用 CSR 创建私有密钥验证证书:
openssl x509 -req \ -inverification_cert_csr_filename.csr\ -CAroot_CA_cert_filename.pem\ -CAkeyroot_CA_key_filename.key\ -CAcreateserial \ -outverification_cert_filename.pem\ -days 500 -sha256 -
在 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。 -
此时,CA 证书已向 Amazon IoT 注册,但未激活。CA 证书必须处于活跃状态,然后您才能注册由其签发的任何客户端证书。
此步骤将激活 CA 证书。
要激活 CA 证书,请使用 update-certificate 命令,如下所示。有关更多信息,请参阅 Amazon CLI 命令参考中的 update-certificate
。 aws iot update-ca-certificate \ --certificate-idcertificateId\ --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 证书
-
在 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-modeSNI_ONLY如果成功,该命令将返回certific
ateId。 -
此时,CA 证书已向注册,Amazon IoT但处于非活动状态。CA 证书必须处于活跃状态,然后您才能注册由其签发的任何客户端证书。
此步骤将激活 CA 证书。
要激活 CA 证书,请使用 update-certificate 命令,如下所示。有关更多信息,请参阅 Amazon CLI 命令参考中的 update-certificate
。 aws iot update-ca-certificate \ --certificate-idcertificateId\ --new-status ACTIVE
要查看 CA 证书的状态,请使用 describe-ca-certificate 命令。有关更多信息,请参阅《Amazon CLI 命令参考》中的 describe-ca-certificate