Yubico / yubikey-manager-qt

Cross-platform application for configuring any YubiKey over all USB interfaces.
https://developers.yubico.com/yubikey-manager-qt/
BSD 2-Clause "Simplified" License
237 stars 30 forks source link

Country name must be a 2 character country code #353

Open Torxed opened 5 months ago

Torxed commented 5 months ago

Steps to reproduce

Applications -> PIV -> Card Authentication -> Generate CSR

Enter the subject string: C=SE/ST=StateName/L=CityName/O=CompanyName/OU=CompanySectionName/CN=Test

Expected result

For this window to produce the CSR at the specified location:

screenshot

Actual results

Failed to generate the CSR with the following stack trace:

Failed to open device
Traceback (most recent call last):
  File "qrc:///py/yubikey.py", line 78, in wrapped
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "qrc:///py/yubikey.py", line 632, in piv_generate_certificate
    csr = generate_csr(session,
          ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ykman/piv.py", line 749, in generate_csr
    parse_rfc4514_string(subject_str)
  File "/usr/lib/python3.11/site-packages/ykman/piv.py", line 141, in parse_rfc4514_string
    parts.append(x509.NameAttribute(attr, v))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/cryptography/x509/name.py", line 142, in __init__
    raise ValueError(
ValueError: Country name must be a 2 character country code
fdennis commented 5 months ago

Try using , instead of / for the subject. In your case C=SE,ST=StateName,L=CityName,O=CompanyName,OU=CompanySectionName,CN=Test

Torxed commented 5 months ago

That worked. Is this intended behavior? As the praxis is / for most libraries and examples.