CA 证书没有将 basicConstraints 扩展设为 true
The CA certificate does not have the basicConstraints extension as true
我正在关注此 AWS GUIDE 创建自签名证书。
但是在创建我的 CA 之后,我尝试将它上传到 AWS IOT 我收到了这个错误:
命令:
aws iot register-ca-certificate --ca-certificate file://CA_cert.pem --verification-cert file://verificationCert.crt
错误:
An error occurred (CertificateValidationException) when calling the RegisterCACertificate operation: CA certificate is not valid. The CA certificate does not have the basicConstraints extension as true
感谢任何帮助!
我也用过 AWS IoT 遇到同样的错误,我找到了解决方案。
错误原因
错误发生是因为 CA 证书中的 basicConstraints
扩展名,这意味着该证书是 CA 因此该证书能够签署其他 public 密钥以生成客户端证书,未设置为TRUE
。
请注意,客户端 X 的证书包含由 CA 的私钥签名的 X 的 public 密钥。其他客户端,例如 Y,可以使用 CA 的 public 密钥验证 X 的 public 密钥。
我认为您在尝试生成 CA 证书时遇到了错误。错误消息表明 CA 的证书不允许签署其他客户端 public 密钥。
以下是我的做法。
解决方案
我假设您已经生成了 CA 的密钥,rootCA.key
。
我们需要一个 openssl
配置文件,比如说 rootCA_openssl.conf
。请注意,您可以修改这些值。
[ req ]
distinguished_name = req_distinguished_name
extensions = v3_ca
req_extensions = v3_ca
[ v3_ca ]
basicConstraints = CA:TRUE
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = KR
countryName_min = 2
countryName_max = 2
organizationName = Organization Name (eg, company)
organizationName_default = Deeply Inc.
然后使用配置文件生成 CA 证书,rootCA_openssl.conf
。
openssl req -new -sha256 -key rootCA.key -nodes -out rootCA.csr -config rootCA_openssl.conf
openssl x509 -req -days 3650 -extfile rootCA_openssl.conf -extensions v3_ca -in rootCA.csr -signkey rootCA.key -out rootCA.pem
现在我们有了 CA 的证书,rootCA.pem
。
然后您可以按照 AWS IoT 文档中的说明进行操作。
例如:
# Get the registration code for the use below:
# $ aws iot get-registration-code
openssl genrsa -out verificationCert.key 2048
openssl req -new -key verificationCert.key -out verificationCert.csr
# Put the registration code in Common Name field
openssl x509 -req -in verificationCert.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out verificationCert.crt -days 500 -sha256
@mctuna 这个(来自 AWS):
生成密钥对。
openssl genrsa -out rootCA.key 2048
使用密钥对中的私钥生成 CA 证书。
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
我正在关注此 AWS GUIDE 创建自签名证书。 但是在创建我的 CA 之后,我尝试将它上传到 AWS IOT 我收到了这个错误:
命令:
aws iot register-ca-certificate --ca-certificate file://CA_cert.pem --verification-cert file://verificationCert.crt
错误:
An error occurred (CertificateValidationException) when calling the RegisterCACertificate operation: CA certificate is not valid. The CA certificate does not have the basicConstraints extension as true
感谢任何帮助!
我也用过 AWS IoT 遇到同样的错误,我找到了解决方案。
错误原因
错误发生是因为 CA 证书中的 basicConstraints
扩展名,这意味着该证书是 CA 因此该证书能够签署其他 public 密钥以生成客户端证书,未设置为TRUE
。
请注意,客户端 X 的证书包含由 CA 的私钥签名的 X 的 public 密钥。其他客户端,例如 Y,可以使用 CA 的 public 密钥验证 X 的 public 密钥。
我认为您在尝试生成 CA 证书时遇到了错误。错误消息表明 CA 的证书不允许签署其他客户端 public 密钥。
以下是我的做法。
解决方案
我假设您已经生成了 CA 的密钥,rootCA.key
。
我们需要一个 openssl
配置文件,比如说 rootCA_openssl.conf
。请注意,您可以修改这些值。
[ req ]
distinguished_name = req_distinguished_name
extensions = v3_ca
req_extensions = v3_ca
[ v3_ca ]
basicConstraints = CA:TRUE
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = KR
countryName_min = 2
countryName_max = 2
organizationName = Organization Name (eg, company)
organizationName_default = Deeply Inc.
然后使用配置文件生成 CA 证书,rootCA_openssl.conf
。
openssl req -new -sha256 -key rootCA.key -nodes -out rootCA.csr -config rootCA_openssl.conf
openssl x509 -req -days 3650 -extfile rootCA_openssl.conf -extensions v3_ca -in rootCA.csr -signkey rootCA.key -out rootCA.pem
现在我们有了 CA 的证书,rootCA.pem
。
然后您可以按照 AWS IoT 文档中的说明进行操作。
例如:
# Get the registration code for the use below:
# $ aws iot get-registration-code
openssl genrsa -out verificationCert.key 2048
openssl req -new -key verificationCert.key -out verificationCert.csr
# Put the registration code in Common Name field
openssl x509 -req -in verificationCert.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out verificationCert.crt -days 500 -sha256
@mctuna 这个(来自 AWS):
生成密钥对。
openssl genrsa -out rootCA.key 2048
使用密钥对中的私钥生成 CA 证书。
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem