【问题标题】:The CA certificate does not have the basicConstraints extension as trueCA 证书没有作为 true 的 basicConstraints 扩展
【发布时间】:2018-10-29 01:43:34
【问题描述】:

我正在关注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

任何帮助表示赞赏!

【问题讨论】:

    标签: amazon-web-services openssl certificate iot aws-iot


    【解决方案1】:

    我也使用过 AWS IoT 并且遇到了同样的错误,我找到了解决方案。

    错误原因

    出现该错误是因为 CA 证书中的 basicConstraints 扩展名,这意味着证书是 CA,因此该证书能够签署其他公钥以生成客户端证书,未设置为 TRUE

    请注意,客户端 X 的证书包含由 CA 的私钥签名的 X 的公钥。其他客户端,例如 Y,可以使用 CA 的公钥验证 X 的公钥。

    我认为您在尝试生成 CA 证书时遇到了错误。该错误消息表明不允许 CA 的证书签署其他客户端公钥。

    以下是我的做法。

    解决方案

    我假设您已经生成了 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.
    

    然后使用配置文件rootCA_openssl.conf生成CA的证书。

    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
    

    【讨论】:

    • @colefner 在第一次尝试时它对我不起作用。我忘记在命令中添加标志-extensions v3_ca。之后它对我有用。
    • 为我工作!如果它不起作用,请仔细检查您是否拥有带有 openssl version 的 openssl 版本 1.1.1
    【解决方案2】:

    @mctuna 与此(来自 AWS):

    生成密钥对。
    openssl genrsa -out rootCA.key 2048

    使用密钥对中的私钥生成 CA 证书。
    openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 2020-02-03
      • 1970-01-01
      • 1970-01-01
      • 2018-04-06
      相关资源
      最近更新 更多