Pular para o conteúdo
ecdsa.com
Go crypto/x509Go

Mensagem de erro

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

Também aparece como

  • 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")

O Go encapsula o erro como “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>\")”. O nome do emissor vem da sua cadeia.

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

O que significa

O Go encontrou um emissor candidato para um certificado (o nome dele aparece entre aspas no final), mas esse emissor não tem permissão para assinar certificados: o basicConstraints dele diz CA:FALSE (ou está ausente), ou o keyUsage dele não inclui keyCertSign. Por isso, o Go o descarta e, sem outro caminho, informa “certificate signed by unknown authority”, citando esse motivo como a causa provável.

Por que acontece

Como corrigir

  1. 1.

    Verificar o basicConstraints e o keyUsage do emissor

    O candidato citado entre aspas precisa ter CA:TRUE e keyCertSign. O OpenSSL 3.5 informa o mesmo defeito como o erro 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.

    Reemitir o intermediário como CA

    Assine-o com basicConstraints crítico CA:TRUE (com o pathlen adequado) e keyUsage keyCertSign, cRLSign; depois, reemita os certificados folha ou monte de novo a cadeia deles.

    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

Erros relacionados

Ver toda a base de erros de assinatura