Mensaje de error
x509: invalid signature: parent certificate cannot sign this kind of certificate
También se muestra 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")
Go lo envuelve así: «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>\")». El nombre del emisor procede de tu cadena.
Go crypto/x509 — ConstraintViolationError: the issuer is not a CA (basicConstraints CA:FALSE or missing keyCertSign)
Qué significa
Go encuentra un emisor candidato para un certificado (su nombre aparece entre comillas al final), pero ese emisor no tiene permiso para firmar certificados: su basicConstraints dice CA:FALSE (o falta), o su keyUsage no incluye keyCertSign. Por eso Go lo descarta y, sin otra ruta posible, informa «certificate signed by unknown authority», con este motivo citado como causa probable.
Por qué ocurre
Certificados firmados con un certificado que no es de CA
frecuenteScripts de PKI caseros que firman certificados de servidor con otro certificado de servidor, o un «intermedio» creado con el perfil predeterminado (no CA).
Un certificado de CA sin keyCertSign
ocasionalUn intermedio con keyUsage = digitalSignature solamente (sin keyCertSign) no puede emitir certificados a ojos de Go.
Un certificado que no es de CA en el archivo de la cadena
ocasionalUn archivo de cadena que contiene otro certificado hoja donde debería ir el intermedio hace que Go pruebe ese certificado hoja como emisor.
Cómo solucionarlo
- 1.
Comprobar basicConstraints y keyUsage del emisor
El candidato citado debe tener CA:TRUE y keyCertSign. OpenSSL 3.5 informa del mismo defecto como error 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.
Volver a emitir el intermedio como CA
Fírmalo con basicConstraints crítica CA:TRUE (con pathlen según corresponda) y keyUsage keyCertSign, cRLSign; después vuelve a emitir los certificados hoja o recompón su cadena.
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