{"record":{"id":"fe793e1c556e07d7","repo":"moodle/moodle","slug":"certificate-not-trusted","errorCode":"CERTIFICATE_NOT_TRUSTED","errorMessage":"error on validating root certificate: ","messagePattern":"error on validating root certificate: ","errorType":"exception","errorClass":"WebAuthnException","httpStatus":null,"severity":"error","filePath":"public/lib/webauthn/src/Attestation/Format/AndroidKey.php","lineNumber":91,"sourceCode":"        // check certificate\n        return \\openssl_verify($dataToVerify, $this->_signature, $publicKey, $coseAlgorithm->openssl) === 1;\n    }\n\n    /**\n     * validates the certificate against root certificates\n     * @param array $rootCas\n     * @return boolean\n     * @throws WebAuthnException\n     */\n    public function validateRootCertificate($rootCas) {\n        $chainC = $this->_createX5cChainFile();\n        if ($chainC) {\n            $rootCas[] = $chainC;\n        }\n\n        $v = \\openssl_x509_checkpurpose($this->getCertificatePem(), -1, $rootCas);\n        if ($v === -1) {\n            throw new WebAuthnException('error on validating root certificate: ' . \\openssl_error_string(), WebAuthnException::CERTIFICATE_NOT_TRUSTED);\n        }\n        return $v;\n    }\n}\n\n","sourceCodeStart":73,"sourceCodeEnd":97,"githubUrl":"https://github.com/moodle/moodle/blob/48ea8c33227277e916cdd4079dbecef448b37f2c/public/lib/webauthn/src/Attestation/Format/AndroidKey.php#L73-L97","documentation":"WebAuthnException::CERTIFICATE_NOT_TRUSTED thrown by AndroidKey's root certificate validation when openssl_x509_checkpurpose() returns -1, meaning the attestation certificate chain could not be verified against the configured root CAs (Google Hardware Attestation Root and any additional CA files). It means the attestation does not chain to a trusted root.","triggerScenarios":"Calling validateAttestation() (which invokes root certificate validation) on an android-key attestation whose x5c chain fails purpose checking: missing/incorrect CA file paths, untrusted or expired chain, or an intermediate CA not supplied.","commonSituations":"Server has no or outdated Google attestation root CA file configured; OpenSSL cannot build the chain because intermediates are absent; expired or revoked attestation certs; emulators/rooted devices producing non-Google-signed chains.","solutions":["Provide the current Google Hardware Attestation Root certificate and correct rootCaFile / additional CA file paths to the Attestation verifier","Confirm openssl_x509_checkpurpose can read each CA file (permissions, PEM format)","Inspect the x5c chain: check validity dates and that all intermediates are included; test the chain with `openssl verify -CAfile root.pem -untrusted chain.pem leaf.pem`","Decide policy: reject the registration, or accept with reduced attestation trust depending on your security requirements"],"exampleFix":"// before\n$rootCas = [$pathToMissingRoot];\n// after\n$rootCas = ['/etc/webauthn/google-hardware-attestation-root.pem']; // valid, current root CA file","handlingStrategy":"try-catch","validationCode":"// verify trust anchors before processing attestations\nforeach ($rootCaFiles as $f) {\n    if (!is_readable($f)) throw new RuntimeException(\"CA file unreadable: $f\");\n}\nopenssl_x509_checkpurpose($leafPem, -1, $rootCas); // pre-check chain locally","typeGuard":null,"tryCatchPattern":"try {\n    $format->validateAttestation($clientDataHash);\n} catch (WebAuthnException $e) {\n    if ($e->getCode() === WebAuthnException::CERTIFICATE_NOT_TRUSTED) {\n        // treat registration as untrusted attestation; apply your policy\n    }\n}","preventionTips":["Ship and refresh the Google Hardware Attestation Root CA file on the server","Verify chains locally with `openssl verify -CAfile root.pem -untrusted chain.pem leaf.pem`","Check certificate expiry dates; renew server-side root store periodically","Define explicit policy for emulator/rooted-device chains"],"tags":["webauthn","android-key","certificate-chain","trust-anchor","openssl"],"backgroundTag":"certificate-verification-failed","analyzedSha":"48ea8c33227277e916cdd4079dbecef448b37f2c","analyzedAt":"2026-09-14T20:34:48.527Z","contentChangedAt":"2026-09-14T20:34:48.527Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}