注册 CA 证书
这些过程描述如何使用 Amazon IoT 注册 CA 证书。
注册 CA 证书(控制台)
若要在控制台中注册 CA 证书,请在控制台中的 Register CA certificate
注册 CA 证书 (CLI)
您可以在 DEFAULT 模式或 SNI_ONLY 模式下注册 CA 证书。有关 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 证书
-
使用 get-registration-code 从 Amazon IoT 获取注册代码。保存返回的
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 证书。将 CA 证书文件名传递给 register-ca-certificate 命令。有关更多信息,请参阅 Amazon CLI 命令参考中的 register-ca-certificate
。 aws iot register-ca-certificate \ --ca-certificate file://root_CA_cert_filename.pem\ --certificate-modeSNI_ONLY如果成功,此命令将返回
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