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 2015511 - 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 7
Classification: Red Hat
Component: certmonger
Version: 7.9
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: ---
Assignee: Rob Crittenden
QA Contact: ipa-qe
URL:
Whiteboard:
Depends On: 2012258
Blocks: 2012261
TreeView+ depends on / blocked
 
Reported: 2021-10-19 11:58 UTC by Rob Crittenden
Modified: 2021-11-23 17:24 UTC (History)
5 users (show)

Fixed In Version: certmonger-0.78.4-17.el7_9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 2012258
Environment:
Last Closed: 2021-11-23 17:17:25 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker FREEIPA-7110 0 None None None 2021-10-19 14:59:50 UTC
Red Hat Issue Tracker RHELPLAN-100242 0 None None None 2021-10-19 15:00:01 UTC
Red Hat Product Errata RHBA-2021:4795 0 None None None 2021-11-23 17:17:28 UTC

Description Rob Crittenden 2021-10-19 11:58:01 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 10 anuja 2021-11-11 07:59:56 UTC
Verified using nightly compose:

[root@master ~]# rpm -qa ipa-server certmonger
certmonger-0.78.4-17.el7_9.x86_64
ipa-server-4.6.8-5.el7_9.9.x86_64
[root@master ~]# vi /var/lib/certmonger/requests/20211111074501 
[root@master ~]# vi fixed
[root@master ~]# ipactl status
Directory Service: RUNNING
krb5kdc Service: RUNNING
kadmin Service: RUNNING
named Service: RUNNING
httpd Service: RUNNING
ipa-custodia Service: RUNNING
ntpd Service: RUNNING
pki-tomcatd Service: RUNNING
ipa-otpd Service: RUNNING
ipa-dnskeysyncd Service: RUNNING
ipa: INFO: The ipactl command was successful
[root@master ~]# openssl asn1parse -inform PEM -in fixed 
    0:d=0  hl=4 l= 881 cons: SEQUENCE          
    4:d=1  hl=4 l= 601 cons: SEQUENCE          
    8:d=2  hl=2 l=   1 prim: INTEGER           :00
   11:d=2  hl=2 l=  36 cons: SEQUENCE          
   13:d=3  hl=2 l=  17 cons: SET               
   15:d=4  hl=2 l=  15 cons: SEQUENCE          
   17:d=5  hl=2 l=   3 prim: OBJECT            :organizationName
   22:d=5  hl=2 l=   8 prim: UTF8STRING        :IPA.TEST
   32:d=3  hl=2 l=  15 cons: SET               
   34:d=4  hl=2 l=  13 cons: SEQUENCE          
   36:d=5  hl=2 l=   3 prim: OBJECT            :commonName
   41:d=5  hl=2 l=   6 prim: PRINTABLESTRING   :IPA RA
   49:d=2  hl=4 l= 290 cons: SEQUENCE          
   53:d=3  hl=2 l=  13 cons: SEQUENCE          
   55:d=4  hl=2 l=   9 prim: OBJECT            :rsaEncryption
   66:d=4  hl=2 l=   0 prim: NULL              
   68:d=3  hl=4 l= 271 prim: BIT STRING        
  343:d=2  hl=4 l= 262 cons: cont [ 0 ]        
  347:d=3  hl=2 l=  43 cons: SEQUENCE          
  349:d=4  hl=2 l=   9 prim: OBJECT            :friendlyName
  360:d=4  hl=2 l=  30 cons: SET               
  362:d=5  hl=2 l=  28 prim: BMPSTRING         
  392:d=3  hl=3 l= 214 cons: SEQUENCE          
  395:d=4  hl=2 l=   9 prim: OBJECT            :Extension Request
  406:d=4  hl=3 l= 200 cons: SET               
  409:d=5  hl=3 l= 197 cons: SEQUENCE          
  412:d=6  hl=2 l= 109 cons: SEQUENCE          
  414:d=7  hl=2 l=   3 prim: OBJECT            :X509v3 Subject Alternative Name
  419:d=7  hl=2 l= 102 prim: OCTET STRING      [HEX DUMP]:3064A024060A2B060104018237140203A0160C14686F73742F6D61737465722E6970612E74657374A03C06062B0601050202A0323030A00A1B084950412E54455354A1223020A003020101A11930171B04686F73741B0F6D61737465722E6970612E74657374
  523:d=6  hl=2 l=  12 cons: SEQUENCE          
  525:d=7  hl=2 l=   3 prim: OBJECT            :X509v3 Basic Constraints
  530:d=7  hl=2 l=   1 prim: BOOLEAN           :255
  533:d=7  hl=2 l=   2 prim: OCTET STRING      [HEX DUMP]:3000
  537:d=6  hl=2 l=  29 cons: SEQUENCE          
  539:d=7  hl=2 l=   3 prim: OBJECT            :X509v3 Subject Key Identifier
  544:d=7  hl=2 l=  22 prim: OCTET STRING      [HEX DUMP]:041413D246A8B3CAFA8787CF3A63EAA22D91A030F218
  568:d=6  hl=2 l=  39 cons: SEQUENCE          
  570:d=7  hl=2 l=   9 prim: OBJECT            :1.3.6.1.4.1.311.20.2
  581:d=7  hl=2 l=  26 prim: OCTET STRING      [HEX DUMP]:1E18006300610053006500720076006500720043006500720074
  609:d=1  hl=2 l=  13 cons: SEQUENCE          
  611:d=2  hl=2 l=   9 prim: OBJECT            :sha256WithRSAEncryption
  622:d=2  hl=2 l=   0 prim: NULL              
  624:d=1  hl=4 l= 257 prim: BIT STRING        
[root@master ~]# 
[root@master ~]# date ; openssl asn1parse -inform PEM -in fixed  | grep -B 1 -A 1 BOOLEAN
Thu Nov 11 02:54:26 EST 2021
  525:d=7  hl=2 l=   3 prim: OBJECT            :X509v3 Basic Constraints
  530:d=7  hl=2 l=   1 prim: BOOLEAN           :255
  533:d=7  hl=2 l=   2 prim: OCTET STRING      [HEX DUMP]:3000
[root@master ~]# 

No boolean value assigned between the SAN and the start of the HEX DUMP.

Comment 14 errata-xmlrpc 2021-11-23 17:17: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 (certmonger 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-2021:4795


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