Description
Version(s) affected
4.7.0
Description
Since #458 this error occurs when registering or validating a key
JsonException(code: 5): Malformed UTF-8 characters, possibly incorrectly encoded at vendor/web-auth/webauthn-lib/src/PublicKeyCredential.php:26
It's triggered from PublicKeyCredentialLoader::loadArray
...
$this->logger->debug('Public Key Credential', [
'publicKeyCredential' => $publicKeyCredential,
]);
this line renders the publicKeyCredential as string, and hits [PublicKeyCredential::__toString
](https://github.com/web-auth/webauthn-framework/blob/87895ca9a1b6064b7e67c320878c09bfe230534d/src/webauthn/src/PublicKeyCredential.php#L26]
return json_encode($this, JSON_THROW_ON_ERROR);
Before #458, the PublicKeyCredential::__toString
method just returned '{}', but now it tries to render the whole AuthenticatorResponse
which contains raw binary data, not compatible with json_encode
How to reproduce
Register or authenticate a key.
This happen to me in https://github.com/asbiin/laravel-webauthn-example/ but I guess it can happen in any application.
Possible Solution
Change the __toString
method to not render the AuthenticatorResponse
?
Additional Context
No response