I was doing some testing of the solo-python library because I wanted to use it. I wanted to read the serial number of the keys to differentiate between two keys that I have added to my laptop. (I want this because you can't have the same resident keys in two solo keys so one needs to know what resident key to expect for a given solo key.) I noticed that only the CLI provided access to the keys.
$ solo ls
:: Solos
207636905548: SoloKeys Solo 4.0.0
However when using python to get information for a given key the serial number is missing:
$ python
Python 3.8.2 (default, Feb 28 2020, 00:00:00)
[GCC 10.0.1 20200216 (Red Hat 10.0.1-0.8)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import solo
>>> solos = solo.client.find()
>>> print(solos.dev.descriptor)
{'path': '/dev/hidraw1', 'usage_page': 61904, 'usage': 1, 'vendor_id': 1155, 'product_id': 41674, 'product_string': 'SoloKeys Solo 4.0.0'}
Ideally the descriptor would also have the serial number information.
I started digging at the code and I found the culprit. The python-fido2 library doesn't parse uevent files fully and misses the serial number entry. But there was a fix within solo in the cli._patches module. Using the solo library through the CLI to get the serial number felt like too much of a hack so I tried to add the fix to the library so it worked accross all functions.
I succeeded in doing so with this patch with which I 'll be making a PR as well.
During the course of all this I noticed that the problem is trully with with the Yubico fido2 python library. The fix on their side would be this patch. The patch was inspired by the solo python _patches fix. If the solo-python maintainers are ok with it I 'd be happy to submit it to the python-fido2 library.
With either fix the code above gives the following result:
$ python
Python 3.8.2 (default, Feb 28 2020, 00:00:00)
[GCC 10.0.1 20200216 (Red Hat 10.0.1-0.8)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import solo
>>> solos = solo.client.find()
>>> print(solos.dev.descriptor)
{'path': '/dev/hidraw1', 'usage_page': 61904, 'usage': 1, 'vendor_id': 1155, 'product_id': 41674, 'product_string': 'SoloKeys Solo 4.0.0', 'serial_number': '207636905548'}
Notice the serial_number entry at the end of the printed dictionary. This allows for easier use of the solo keys serial number within a python program in order to differentiate between solo keys.
I was doing some testing of the
solo-python
library because I wanted to use it. I wanted to read the serial number of the keys to differentiate between two keys that I have added to my laptop. (I want this because you can't have the same resident keys in two solo keys so one needs to know what resident key to expect for a given solo key.) I noticed that only the CLI provided access to the keys.However when using python to get information for a given key the serial number is missing:
Ideally the descriptor would also have the serial number information.
I started digging at the code and I found the culprit. The
python-fido2
library doesn't parseuevent
files fully and misses the serial number entry. But there was a fix within solo in the cli._patches module. Using the solo library through the CLI to get the serial number felt like too much of a hack so I tried to add the fix to the library so it worked accross all functions.I succeeded in doing so with this patch with which I 'll be making a PR as well.
During the course of all this I noticed that the problem is trully with with the Yubico fido2 python library. The fix on their side would be this patch. The patch was inspired by the solo python _patches fix. If the solo-python maintainers are ok with it I 'd be happy to submit it to the python-fido2 library.
With either fix the code above gives the following result:
Notice the
serial_number
entry at the end of the printed dictionary. This allows for easier use of the solo keys serial number within a python program in order to differentiate between solo keys.