微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

发现webauthn

如何解决发现webauthn

我是webauthn的新手,我从头开始学习。

我正在使用网站https://webauthn.guide/#registration作为参考...

我被困在cbor的解码中

attStmt块为空白,而authData块被截断...

JS

const CreateCredentialOptions = {
 ...
}
navigator.credentials.create({
  publicKey: CreateCredentialOptions
})
.then((AttestationRaw) => {
  let ClientData = new TextDecoder('utf-8');
  ClientData = ClientData.decode(AttestationRaw.response.clientDataJSON)
  ClientData = JSON.parse(ClientData);
  window.open('teste.PHP?a='+JSON.stringify(
    {
      id: btoa(AttestationRaw.rawId),clientDataJSON: ClientData,attestationObject: JSON.stringify(Array.from(new Uint8Array(AttestationRaw.response.attestationObject)))
    }
  ))
})

PHP

echo '<pre>';
$a = json_decode($_GET['a']);
$a = $a->attestationObject;
$a = json_decode($a);
$final = '';
foreach($a as $b):
  $final .= chr($b);
endforeach;
$a = CBOREncoder::decode($final);
vd($a);

结果

object(stdClass)#1 (3) {
  ["id"]=>
  string(28) "W29iamVjdCBBcnJheUJ1ZmZlcl0="
  ["clientDataJSON"]=>
  object(stdClass)#2 (4) {
    ["type"]=>
    string(15) "webauthn.create"
    ["challenge"]=>
    string(30) "Z243aHE5OGhnbjM5aDNndzlhc2hzOQ"
    ["origin"]=>
    string(31) "https://estrategiagestao.com.br"
    ["crossOrigin"]=>
    bool(false)
  }
  ["attestationObject"]=>
  string(1349) "[...]"
}
array(3) {
  ["fmt"]=>
  string(4) "none"
  ["attStmt"]=>
  array(0) {
  }
  ["authData"]=>
  object(CBORByteString)#1 (1) {
    ["byte_string":"CBORByteString":private]=>
    string(359) "�U�hR���m�*�>�>�%_�E

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。