Bug 2323702 - KEYNAME len > 128 --> openssl error
Summary: KEYNAME len > 128 --> openssl error
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: akmods
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Nicolas Chauvet (kwizart)
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-11-04 18:20 UTC by Fabrice Bellet
Modified: 2024-11-28 08:33 UTC (History)
9 users (show)

Fixed In Version: akmods-0.6.0-6.fc42
Clone Of:
Environment:
Last Closed: 2024-11-28 08:18:34 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Fabrice Bellet 2024-11-04 18:20:08 UTC
Hi!

It appears that  KEYNAME changed between F40 and F41 in kmodgenca:

was:

KEYNAME="$(hostname)"-"$(od -vAn -N4 -tu4 < /dev/urandom | awk '{print $1}')"

now is:

KEYNAME="$(hostname)_$(date +%s)_$(uuidgen | tr -d '-')"


The problem is that the new keyname has more risks to be longer than 64 bytes, which causes this error when generating the certificate:

Error making certificate request
80F2426AE87F0000:error:06800097:asn1 encoding routines:ASN1_mbstring_ncopy:string too long:crypto/asn1/a_mbstr.c:106:maxsize=64





Reproducible: Always

Comment 1 Nicolas Chauvet (kwizart) 2024-11-05 23:26:00 UTC
Thanks for the report.
Can you suggest a fix ? this keyname looks overthought. Using a timestamp seems like way enough, this isn't an entropy contest.

Also full hostname can be long, maybe we need to lower to hostname -s if kept. (or truncate to 64 bytes).

Comment 2 Jonathan Billings 2024-11-07 18:22:30 UTC
Unfortunately, this change breaks the graphical automatic NVIDIA driver install in Fedora Workstation if your hostname is > 20 characters long.

It looks like as long as your hostname is 20 characters or shorter, it will work, but if $HOSTNAME is more than 20 characters, it fails.  

Perhaps instead of using $(hostname), you could set cert_hostname=$(hostname) and then set KEYNAME with:

cert_hostname="$(hostname)"
KEYNAME="${cert_hostname:0:20}_$(date +%s)_$(uuidgen | tr -d '-')"

This just uses the first 20 characters of the hostname if its longer, if its shorter nothing changes.

Comment 3 Jonathan Billings 2024-11-07 18:48:32 UTC
of course $(date +%s) will eventually become more characters, but that won't happen until November 20th, 2286.

Comment 4 Clemens Lang 2024-11-08 11:00:16 UTC
Why is $(date +%s) even required if there's already a UUID in the certificate name? The UUID is already supposed to be globally unique, why attempt to distinguish it further using a timestamp?

Also, aren't those X.509 certificates, i.e., they have a Not Before date that will default to the current timestamp anyway, so the date +%s is absolutely redundant because the same information is available from the certificate?

Comment 5 Nicolas Chauvet (kwizart) 2024-11-08 13:30:19 UTC
I would fix with :

cert_hostname="$(hostname)"
KEYNAME="${cert_hostname:0:44}_$(date +%s)_$(uuidgen | awk -F '-' '{print $1}')"

> Why is $(date +%s) even required if there's already a UUID in the certificate name? 
Indeed, only to provide randomness for the certificate name that is under a second with the uuid part. But as I said, this looks way too much overthought in the first step.

The only point I get is if one or another domain have special characters that would fix in a filename but not in a certificate name. But at that point, it's no more a regression from the previous situation.

Comment 6 Nicolas Chauvet (kwizart) 2024-11-28 08:18:34 UTC
Fixed in https://bodhi.fedoraproject.org/updates/FEDORA-2024-3cb2996a3a

Comment 7 Fedora Update System 2024-11-28 08:29:25 UTC
FEDORA-2024-471d003d9b (akmods-0.6.0-6.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-471d003d9b

Comment 8 Fedora Update System 2024-11-28 08:33:22 UTC
FEDORA-2024-471d003d9b (akmods-0.6.0-6.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.