Bug 2121044

Summary: Error parsing EK ASN.1 certificate of Nuvoton HW TPM
Product: Red Hat Enterprise Linux 9 Reporter: Karel Srot <ksrot>
Component: keylimeAssignee: Sergio Correia <scorreia>
Status: CLOSED ERRATA QA Contact: Karel Srot <ksrot>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 9.0CC: ansasaki, dueno
Target Milestone: rcKeywords: Rebase, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: keylime-6.4.3-1.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 10:34:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Karel Srot 2022-08-24 10:34:57 UTC
Description of problem:

This is tracked upstream in https://github.com/keylime/keylime/issues/944

When running the basic attestation scenario on localhost the agent fails to register and the following message is logged by registrar

2022-03-28 05:42:13,737 keylime.tpm INFO TPM2-TOOLS Version: 5.0
2022-03-28 05:42:13,752 keylime.registrar WARNING POST for d432fbb3-d2f1-4a97-9ef7-75bd81c00000 returning 400 response. Error: error parsing asn1 value: ParseError { kind: InvalidSetOrdering, location: ["RawCertificate::tbs_cert", "TbsCertificate::issuer", "0", "2"] }
2022-03-28 05:42:13,752 keylime.registrar WARNING POST for d432fbb3-d2f1-4a97-9ef7-75bd81c00000 returning 400 response. Error: error parsing asn1 value: ParseError { kind: InvalidSetOrdering, location: ["RawCertificate::tbs_cert", "TbsCertificate::issuer", "0", "2"] }
2022-03-28 05:42:13,753 keylime.registrar ERROR error parsing asn1 value: ParseError { kind: InvalidSetOrdering, location: ["RawCertificate::tbs_cert", "TbsCertificate::issuer", "0", "2"] }
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/keylime-6.3.1-py3.9.egg/keylime/registrar_common.py", line 287, in do_POST
    ek509 = load_der_x509_certificate(
  File "/usr/local/lib64/python3.9/site-packages/cryptography/x509/base.py", line 538, in load_der_x509_certificate
    return rust_x509.load_der_x509_certificate(data)
ValueError: error parsing asn1 value: ParseError { kind: InvalidSetOrdering, location: ["RawCertificate::tbs_cert", "TbsCertificate::issuer", "0", "2"] }

I have tested it also with the latest cryptography module available in PIP v36.0.2, same behavior.

TPM EK cert cannot be parsed by cryptography module but it can be parsed by openssl (openssl-3.0.1)

---

The issuer attribute seems non standard: Issuer: CN = Nuvoton TPM Root CA 2110 + O = Nuvoton Technology Corporation + C = TW. Normally those fields should be comma separated not with a +.

The issue is likely in the ASN.1 parser used by cryptography.


Version-Release number of selected component (if applicable):
keylime-6.4.2-2.el9

Comment 9 errata-xmlrpc 2022-11-15 10:34:25 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (keylime bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:8189