moodle/moodle · error · WebAuthnException
CERTIFICATE_NOT_TRUSTED
CERTIFICATE_NOT_TRUSTED
Error message
error on validating root certificate:
What it means
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.
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
Example fix
// before $rootCas = [$pathToMissingRoot]; // after $rootCas = ['/etc/webauthn/google-hardware-attestation-root.pem']; // valid, current root CA file
Defensive patterns
Strategy: try-catch
Validate before calling
// verify trust anchors before processing attestations
foreach ($rootCaFiles as $f) {
if (!is_readable($f)) throw new RuntimeException("CA file unreadable: $f");
}
openssl_x509_checkpurpose($leafPem, -1, $rootCas); // pre-check chain locally Try / catch
try {
$format->validateAttestation($clientDataHash);
} catch (WebAuthnException $e) {
if ($e->getCode() === WebAuthnException::CERTIFICATE_NOT_TRUSTED) {
// treat registration as untrusted attestation; apply your policy
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
Related errors
- error on validating root certificate: ' …
- error on validating root certificate: ' …
- error on validating root certificate: ' …
- error on validating root certificate: ' …
- INVALID_PUBLIC_KEY
AI-assisted analysis of moodle/moodle@48ea8c3322 (2026-09-14).
Data as JSON: /api/errors/fe793e1c556e07d7.
Report an issue: GitHub.
Appendix: source
Thrown at public/lib/webauthn/src/Attestation/Format/AndroidKey.php:91
// check certificate
return \openssl_verify($dataToVerify, $this->_signature, $publicKey, $coseAlgorithm->openssl) === 1;
}
/**
* validates the certificate against root certificates
* @param array $rootCas
* @return boolean
* @throws WebAuthnException
*/
public function validateRootCertificate($rootCas) {
$chainC = $this->_createX5cChainFile();
if ($chainC) {
$rootCas[] = $chainC;
}
$v = \openssl_x509_checkpurpose($this->getCertificatePem(), -1, $rootCas);
if ($v === -1) {
throw new WebAuthnException('error on validating root certificate: ' . \openssl_error_string(), WebAuthnException::CERTIFICATE_NOT_TRUSTED);
}
return $v;
}
}
View on GitHub (pinned to 48ea8c3322)