Yubico / yubikey-manager

Python library and command line tool for configuring any YubiKey over all USB interfaces.
https://developers.yubico.com/yubikey-manager/
BSD 2-Clause "Simplified" License
867 stars 125 forks source link

ykman oauth accounts add crashing #579

Closed marcaurele closed 8 months ago

marcaurele commented 10 months ago

Steps to reproduce

> ykman oath accounts add  --issuer "My Issuer" "account-name"
Enter a secret key (base32): <paste the secret>

Expected result

The account to be correctly added to the key.

Actual results and logs

Traceback (most recent call last):
  File "/usr/bin/ykman", line 33, in <module>
    sys.exit(load_entry_point('yubikey-manager==4.0.9', 'console_scripts', 'ykman')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/ykman/cli/__main__.py", line 378, in main
    cli(obj={})
  File "/usr/lib/python3/dist-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/ykman/cli/oath.py", line 425, in add
    _add_cred(
  File "/usr/lib/python3/dist-packages/ykman/cli/oath.py", line 516, in _add_cred
    session.put_credential(data, touch)
  File "/usr/lib/python3/dist-packages/yubikit/oath.py", line 331, in put_credential
    self.protocol.send_apdu(0, INS_PUT, 0, 0, data)
  File "/usr/lib/python3/dist-packages/yubikit/core/smartcard.py", line 177, in send_apdu
    raise ApduError(response, sw)
yubikit.core.smartcard.ApduError: APDU error: SW=0x6a80

Other info

ykman info                                                                                                           
Device type: YubiKey 5C NFC
Serial number: XXXXXXXX
Firmware version: 5.2.7
Form factor: Keychain (USB-C)
Enabled USB interfaces: CCID
NFC transport is enabled.

Applications    USB             NFC          
FIDO2           Disabled        Enabled         
OTP             Disabled        Enabled         
FIDO U2F        Disabled        Enabled         
OATH            Enabled         Enabled         
YubiHSM Auth    Not available   Not available   
OpenPGP         Enabled         Enabled         
PIV             Enabled         Enabled         
dainnilsson commented 10 months ago

It looks like you're using a rather old version of ykman (4.0.9). Please try with the latest release (5.2.1) and see if the problem persists there. You may need to install it via pip rather than apt.