本文へスキップ
ecdsa.com
Go crypto/x509Go

エラーメッセージ

x509: invalid signature: parent certificate cannot sign this kind of certificate

別の表記

  • x509: certificate signed by unknown authority (possibly because of "x509: invalid signature: parent certificate cannot sign this kind of certificate" while trying to verify candidate authority certificate "Example Issuing Server")

Go はこれを「x509: certificate signed by unknown authority (possibly because of \"x509: invalid signature: parent certificate cannot sign this kind of certificate\" while trying to verify candidate authority certificate \"<issuer CN>\")」という形で報告します。発行者名は、対象のチェーンから取られます。

Go crypto/x509 — ConstraintViolationError: the issuer is not a CA (basicConstraints CA:FALSE or missing keyCertSign)

このエラーの意味

Go は証明書の発行者の候補(末尾に引用符付きで示される名前)を見つけましたが、その発行者には証明書に署名する権限がありません。basicConstraints が CA:FALSE になっている(または basicConstraints がない)か、keyUsage に keyCertSign が含まれていません。そのため Go はこの候補を除外し、ほかにパスがないので「certificate signed by unknown authority」と報告して、考えられる原因としてこの理由を引用します。

発生する理由

修正方法

  1. 1.

    発行者の basicConstraints と keyUsage を確認する

    引用符で示された候補には、CA:TRUE と keyCertSign が必要です。OpenSSL 3.5 は、同じ欠陥をエラー 79「invalid CA certificate」として報告します。

    bash
    # Every issuing certificate needs CA:TRUE (and keyCertSign if keyUsage is present)
    openssl x509 -in intermediate.pem -noout -subject -ext basicConstraints,keyUsage
    openssl verify -CAfile root.pem -untrusted intermediate.pem server.pem   # OpenSSL 3.5: error 79, invalid CA certificate
  2. 2.

    中間証明書を CA として再発行する

    basicConstraints を critical の CA:TRUE(pathlen は必要に応じて)、keyUsage を keyCertSign、cRLSign にして署名し、その後リーフ証明書を再発行するか、チェーンをつなぎ直してください。

    bash
    # Issue the intermediate as a real CA
    printf 'basicConstraints=critical,CA:TRUE,pathlen:0\nkeyUsage=critical,keyCertSign,cRLSign\n' > ca.ext
    openssl x509 -req -in int.csr -CA root.pem -CAkey root.key -days 1825 -extfile ca.ext -out int.pem

関連するエラー

署名エラーデータベースをすべて見る