RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2012261 - certmonger creates CSRs with invalid DER syntax for X509v3 extensions with critical=FALSE
Summary: certmonger creates CSRs with invalid DER syntax for X509v3 extensions with cr...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: certmonger
Version: 9.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: ---
Assignee: Rob Crittenden
QA Contact: ipa-qe
URL:
Whiteboard:
Depends On: 2012258 2015511
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-10-08 17:05 UTC by Rob Crittenden
Modified: 2022-05-17 13:29 UTC (History)
3 users (show)

Fixed In Version: certmonger-0.79.14-5.el9
Doc Type: Bug Fix
Doc Text:
Cause: certmonger is encoding a DER default boolean value in the Certificate Signing Request it generates. Consequence: The resulting CSR is not compliant with strict DER readers Fix: Apply the OPTIONAL flag and use the upstream NSS CSR template. Result: The CSR that certmonger generates is valid.
Clone Of: 2012258
Environment:
Last Closed: 2022-05-17 13:13:50 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker FREEIPA-7060 0 None None None 2021-10-08 17:06:26 UTC
Red Hat Issue Tracker RHELPLAN-99314 0 None None None 2021-10-08 17:06:30 UTC
Red Hat Product Errata RHBA-2022:2478 0 None None None 2022-05-17 13:13:56 UTC

Description Rob Crittenden 2021-10-08 17:05:00 UTC
+++ This bug was initially created as a clone of Bug #2012258 +++

Description of problem:

certmonger's template for X509v3 extensions is wrong and generate invalid DER for extensions with critical=FALSE. Since FALSE is the default value, a standard conform CSR or cert must not encode the critical flag.

$ openssl asn1parse -inform PEM -in freeipa.csr
...
  421:d=7  hl=2 l=   3 prim: OBJECT            :X509v3 Subject Alternative Name
  426:d=7  hl=2 l=   1 prim: BOOLEAN           :0
  429:d=7  hl=3 l= 135 prim: OCTET STRING      [HEX DUMP]:...

The line BOOLEAN 0 should not be present.

/* RFC 5280, 4.1 */
const SEC_ASN1Template
cm_certext_cert_extension_template[] = {
        {
        .kind = SEC_ASN1_SEQUENCE,
        .offset = 0,
        .sub = NULL,
        .size = sizeof(CERTCertExtension),
        },
        {
        .kind = SEC_ASN1_OBJECT_ID,
        .offset = offsetof(CERTCertExtension, id),
        .sub = NULL,
        .size = sizeof(SECItem),
        },
        {
        .kind = SEC_ASN1_BOOLEAN,
        .offset = offsetof(CERTCertExtension, critical),
        .sub = NULL,
        .size = sizeof(SECItem),
        },
        {
        .kind = SEC_ASN1_OCTET_STRING,
        .offset = offsetof(CERTCertExtension, value),
        .sub = NULL,
        .size = sizeof(SECItem),
        },
        {0, 0, NULL, 0},
};

The correct kind for the critical extension is SEC_ASN1_OPTIONAL | SEC_ASN1_BOOLEAN.

    https://github.com/servo/nss/blob/949eb9848f4fa5f83756f3ab7fdf9b0d3f20d37f/lib/certdb/certdb.c#L50
    https://github.com/pyca/cryptography/issues/6368
    https://pagure.io/freeipa/issue/9005

Version-Release number of selected component (if applicable):

certmonger-0.79.13-3

How reproducible:


Steps to Reproduce:
1. install an IPA server
2. pull the csr= value from /var/lib/certmonger/reqeusts/<some id> into a separate file
3. openssl asn1parse -inform PEM -in /path/to/file

Expected results:

There should be no BOOLEAN value for the critical flag, so nothing between the SAN and the start of the HEX DUMP.

--- Additional comment from Rob Crittenden on 2021-10-08 17:04:16 UTC ---

Fixed in master:

9312d1892c611d9f0e814cb915488182da2b76cc
e3e4679693efc60bc7a25983909ddfa6883ab2ec

Comment 1 Rob Crittenden 2021-10-08 17:10:41 UTC
Fixed in master:

9312d1892c611d9f0e814cb915488182da2b76cc
e3e4679693efc60bc7a25983909ddfa6883ab2ec

Comment 10 Mohammad Rizwan 2021-12-06 07:30:33 UTC
version:
certmonger-0.79.14-5.el9.x86_64

[root@master ~]#  openssl asn1parse -inform PEM -in  csr.csr 
    0:d=0  hl=4 l= 987 cons: SEQUENCE          
    4:d=1  hl=4 l= 707 cons: SEQUENCE          
    8:d=2  hl=2 l=   1 prim: INTEGER           :00
   11:d=2  hl=2 l=  55 cons: SEQUENCE          
   13:d=3  hl=2 l=  22 cons: SET               
   15:d=4  hl=2 l=  20 cons: SEQUENCE          
   17:d=5  hl=2 l=   3 prim: OBJECT            :organizationName
   22:d=5  hl=2 l=  13 prim: UTF8STRING        :TESTRELM.TEST
   37:d=3  hl=2 l=  29 cons: SET               
   39:d=4  hl=2 l=  27 cons: SEQUENCE          
   41:d=5  hl=2 l=   3 prim: OBJECT            :commonName
   46:d=5  hl=2 l=  20 prim: PRINTABLESTRING   :master.testrelm.test
   68:d=2  hl=4 l= 290 cons: SEQUENCE          
   72:d=3  hl=2 l=  13 cons: SEQUENCE          
   74:d=4  hl=2 l=   9 prim: OBJECT            :rsaEncryption
   85:d=4  hl=2 l=   0 prim: NULL              
   87:d=3  hl=4 l= 271 prim: BIT STRING        
  362:d=2  hl=4 l= 349 cons: cont [ 0 ]        
  366:d=3  hl=2 l=  43 cons: SEQUENCE          
  368:d=4  hl=2 l=   9 prim: OBJECT            :friendlyName
  379:d=4  hl=2 l=  30 cons: SET               
  381:d=5  hl=2 l=  28 prim: BMPSTRING         
  411:d=3  hl=4 l= 300 cons: SEQUENCE          
  415:d=4  hl=2 l=   9 prim: OBJECT            :Extension Request
  426:d=4  hl=4 l= 285 cons: SET               
  430:d=5  hl=4 l= 281 cons: SEQUENCE          
  434:d=6  hl=3 l= 184 cons: SEQUENCE          
  437:d=7  hl=2 l=   3 prim: OBJECT            :X509v3 Subject Alternative Name
  442:d=7  hl=3 l= 176 prim: OCTET STRING      [HEX DUMP]:3081AD82146D61737465722E7465737472656C6D2E7465737482146970612D63612E7465737472656C6D2E74657374A037060A2B060104018237140203A0290C27485454502F6D61737465722E7465737472656C6D2E74657374405445535452454C4D2E54455354A04606062B0601050202A03C303AA00F1B0D5445535452454C4D2E54455354A1273025A003020101A11E301C1B04485454501B146D61737465722E7465737472656C6D2E74657374
  621:d=6  hl=2 l=  12 cons: SEQUENCE          
  623:d=7  hl=2 l=   3 prim: OBJECT            :X509v3 Basic Constraints
  628:d=7  hl=2 l=   1 prim: BOOLEAN           :255
  631:d=7  hl=2 l=   2 prim: OCTET STRING      [HEX DUMP]:3000
  635:d=6  hl=2 l=  29 cons: SEQUENCE          
  637:d=7  hl=2 l=   3 prim: OBJECT            :X509v3 Subject Key Identifier
  642:d=7  hl=2 l=  22 prim: OCTET STRING      [HEX DUMP]:0414C059283DF9E5D1C3F46A90BAB72AFA144D06415C
  666:d=6  hl=2 l=  47 cons: SEQUENCE          
  668:d=7  hl=2 l=   9 prim: OBJECT            :1.3.6.1.4.1.311.20.2
  679:d=7  hl=2 l=  34 prim: OCTET STRING      [HEX DUMP]:1E200063006100490050004100730065007200760069006300650043006500720074
  715:d=1  hl=2 l=  13 cons: SEQUENCE          
  717:d=2  hl=2 l=   9 prim: OBJECT            :sha256WithRSAEncryption
  728:d=2  hl=2 l=   0 prim: NULL              
  730:d=1  hl=4 l= 257 prim: BIT STRING        
[root@master ~]# 



There is no boolean between SAN and hex dump, Hence marking as verified.

Comment 12 errata-xmlrpc 2022-05-17 13:13:50 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 (new packages: certmonger), 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:2478


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