java – WebAuthn “Failed to parse credential public key”


I am trying to implement WebAuthn into my Java Web Application.
I have implemented the register function according to the Yubico Quickstart Guide, but when validating the final response from the Client I get the following error:

java.lang.RuntimeException: Failed to parse credential public key
(...)
Caused by: COSE.CoseException: Missing or incorrect key type field

This is my code for finishing the register function:

PublicKeyCredential<AuthenticatorAttestationResponse, ClientRegistrationExtensionOutputs> pkc =
    PublicKeyCredential.parseRegistrationResponseJson(responseJson);
System.out.println("pkc: " + pkc);
// Validate the response
try {
   RegistrationResult result = WebAuthnConfig.RP
      .finishRegistration(FinishRegistrationOptions.builder()
      .request(WebAuthnConfig.PK_REQUEST)
      .response(pkc)
      .build());
} catch (RegistrationFailedException e) {
        e.printStackTrace();
}

The pkc variable looks the following:

PublicKeyCredential(
   id=ByteArray(c47fddb8101a335...),
   response=AuthenticatorAttestationResponse(
      attestationObject=ByteArray(a363666d74667...), 
      clientDataJSON=ByteArray(7b226368616c6c6...),
      attestation=AttestationObject(
         bytes=ByteArray(a363666d74667061636b656467617...
      ), 
      authenticatorData=AuthenticatorData(
         bytes=ByteArray(49960de5880e8c687...),
         flags=AuthenticatorDataFlags(value=69, UP=true, UV=true, AT=true, ED=false), 
         attestedCredentialData=Optional(
            AttestedCredentialData(
               aaguid=ByteArray(8976631bd4a0427f...),    
               credentialId=ByteArray(c47fddb8101a...), 
               credentialPublicKey=ByteArray(a50102032620012158...)
            )
         ),
         extensions=Optional.empty
      ),
      format=packed,
      attestationStatement={
         "alg":-7,
         "sig":"MEYCIQDBofIhso...",
         "x5c":("MIIC4TCCAo...")
      }
   ),
   clientData=CollectedClientData(
      clientDataJson=ByteArray(7b22636...),
      clientData={
         "challenge":"dPV2ukXdZzp...",
         "clientExtensions":{},
         "hashAlgorithm":"SHA-256",
         "origin":"https://localhost",
         "type":"webauthn.create"
      },
      challenge=ByteArray(74f576ba45...),
      origin=https://localhost,
      type=webauthn.create)
   ),
   clientExtensionResults=ClientRegistrationExtensionOutputs(),
   type=PUBLIC_KEY
)

And the OK_REQUEST as follows:

PublicKeyCredentialCreationOptions(
   rp=RelyingPartyIdentity(
      name=WebApp WebAuthn,
      id=localhost, 
      icon=Optional.empty
   ), 
   user=UserIdentity(
      name=((${#authentication.getPrincipal().getUsername()})), 
      displayName=null null,  
   id=ByteArray(d72a3a2...),
   icon=Optional.empty), 
   challenge=ByteArray(74f576...),
   pubKeyCredParams=(
      PublicKeyCredentialParameters(
         alg=ES256, 
         type=PUBLIC_KEY
      ),
      PublicKeyCredentialParameters(
         alg=EdDSA, 
         type=PUBLIC_KEY
      ),
      PublicKeyCredentialParameters(
         alg=RS256, 
         type=PUBLIC_KEY
      )
   ), 
   timeout=Optional.empty, 
   excludeCredentials=Optional.empty, 
   authenticatorSelection=Optional.empty, 
   attestation=NONE, 
   extensions=RegistrationExtensionInputs()
)

I can’t figure out what exactly the error is complaining about, could anyone help me with this or how I could properly debug this issue?