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 1551702 - certmonger unit test fails with SEC_ERROR_BAD_DER
Summary: certmonger unit test fails with SEC_ERROR_BAD_DER
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: certmonger
Version: 7.5
Hardware: Unspecified
OS: Unspecified
high
urgent
Target Milestone: rc
: ---
Assignee: Rob Crittenden
QA Contact: ipa-qe
URL:
Whiteboard:
Depends On:
Blocks: 1551635 1560960
TreeView+ depends on / blocked
 
Reported: 2018-03-05 19:09 UTC by Rob Crittenden
Modified: 2018-10-30 07:44 UTC (History)
14 users (show)

Fixed In Version: certmonger-0.78.4-4.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1560960 (view as bug list)
Environment:
Last Closed: 2018-10-30 07:44:03 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
cert.nss.2048 (1.91 KB, text/plain)
2018-03-05 20:41 UTC, Kai Engert (:kaie) (inactive account)
no flags Details
raw DER encoding of cert.nss.2048 (1.37 KB, application/octet-stream)
2018-03-05 20:41 UTC, Kai Engert (:kaie) (inactive account)
no flags Details
stack.txt (8.93 KB, text/plain)
2018-03-05 20:42 UTC, Kai Engert (:kaie) (inactive account)
no flags Details
cert text dump (6.98 KB, text/plain)
2018-03-05 20:45 UTC, Kai Engert (:kaie) (inactive account)
no flags Details
minimal reproducer (2.87 KB, text/plain)
2018-03-07 08:13 UTC, Daiki Ueno
no flags Details
Daiki's suggested fix as a patch to certmonger (342 bytes, patch)
2018-03-07 10:22 UTC, Kai Engert (:kaie) (inactive account)
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:3018 0 None None None 2018-10-30 07:44:55 UTC

Description Rob Crittenden 2018-03-05 19:09:33 UTC
Description of problem:
certmonger unit test 004-selfsign-dsa is failing:

Generating key.  This may take a few moments...

Notice: Trust flag u is set automatically if the private key is present.
2018-03-05 13:38:56 [24095] Found token 'NSS Certificate DB'.
2018-03-05 13:38:56 [24095] Located a certificate with the key's nickname ("keyi2048").
2018-03-05 13:38:56 [24095] Located its private key.
2018-03-05 13:38:56 [24095] Recovered public key from private key.
2018-03-05 13:38:56 [24098] Found token 'NSS Certificate DB'.
2018-03-05 13:38:56 [24098] Located a certificate with the key's nickname ("keyi2048").
2018-03-05 13:38:56 [24098] Located its private key.
2018-03-05 13:38:56 [24098] Recovered public key from private key.
2018-03-05 13:38:56 [24098] Setting certificate serial number "04".
2018-03-05 13:38:56 [24106] Setting certificate serial number "04".
error in verification: SEC_ERROR_BAD_DER
error in verification: SEC_ERROR_BAD_DER
Test complete.

The test works with RHEL 7.4 nss-3.28.4-15.el7_4.x86_64 and no certmonger code changed in the interm.

Version-Release number of selected component (if applicable):
nss-3.34.0-4.el7.x86_64

How reproducible:

Every time

Steps to Reproduce:
1. Try to build certmonger in RHEL 7.5

Additional info:

A way to debug is in-tree in the certmonger source is to modify run.sh to include something like:

tmpdir="/tmp/foo"
srcdir="/home/<yourname>/rpmbuild/BUILD/certmonger-0.78.4/tests"
toolsdir="/home/<yourname>/rpmbuild/BUILD/certmonger-0.78.4/tests/tools"

CERTMONGER_CONFIG_DIR=${srcdir}
export CERTMONGER_CONFIG_DIR

cd "$tmpdir"

Now you can execute run.sh directly.

I did this by executing rpmbuild --rebuild certmonger-0.78.4-3.el7.src.rpm and then switching to the BUILD directory after the tests fail.

It also fails in 004-selfsign-ec

Comment 8 Kai Engert (:kaie) (inactive account) 2018-03-05 20:41:05 UTC
Created attachment 1404489 [details]
cert.nss.2048

Comment 9 Kai Engert (:kaie) (inactive account) 2018-03-05 20:41:47 UTC
Created attachment 1404490 [details]
raw DER encoding of cert.nss.2048

Comment 10 Kai Engert (:kaie) (inactive account) 2018-03-05 20:42:37 UTC
Created attachment 1404491 [details]
stack.txt

Comment 11 Kai Engert (:kaie) (inactive account) 2018-03-05 20:45:20 UTC
Created attachment 1404504 [details]
cert text dump

Bob, Hubert, any idea what properties of this certificate could cause NSS 3.36 to fail decoding this certificate with BAD_DER, while NSS 3.28 had worked?

Well, I don't know if this encoding is valid. Another potential explanation could be that NSS 3.36 produced an invalid encoding.

Comment 12 Alicja Kario 2018-03-06 15:19:00 UTC
I've got no clue, it looks sane and openssl parses it without issue, but it complaints about not being able to get issuer, despite this cert looking self-signed:

$ openssl verify -CAfile cert.nss.2048 cert.nss.2048
CN = Babs Jensen
error 20 at 0 depth lookup: unable to get local issuer certificate
error cert.nss.2048: verification failed

maybe "X509v3 Subject Key Identifier" is calculated wrong?

Comment 14 Kai Engert (:kaie) (inactive account) 2018-03-06 15:24:24 UTC
This bug is seen with NSS 3.34. It might be worth repeating the test with the nss-softokn 3.36 packages that Daiki is currently working on. Although I don't have a lot of hope that it makes a difference.

Comment 19 Daiki Ueno 2018-03-07 08:13:57 UTC
Created attachment 1405176 [details]
minimal reproducer

OK, I realized that this is a problem in the test program (it worked before because the old decoder is more tolerant about the length).  When decoding BIT_STRING either with the old decoder or QuickDER, the length is returned in the number of bits instead of octets; so 504 / 8 = 64.

On the other hand, VFY_VerifyDataWithAlgorithmIDI() expects octet length for the signature value.  So you need to adjust it with something like:

  signed_data.signature.len /= 8;

before calling that function.

I am attaching the standalone version of checksig.c, which can be compiled with:

  $ gcc -o checksig checksig.c `pkg-config nss --cflags --libs`

Feed the "der" file attached at comment 9:

  $ cat der | ./checksig
  error in verification: SEC_ERROR_BAD_DER

If you comment out the line 95 (which adds the above adjustment) and recompile it:

  $ cat der | ./checksig
  verification OK

Comment 20 Kai Engert (:kaie) (inactive account) 2018-03-07 10:22:00 UTC
Bob, thanks for the analysis.
Daiki, thanks for identifying the fix!

I'm attaching Daiki's suggested fix, and reassigning to certmonger.

Rob, could you please verify it fixes the issue?

Comment 21 Kai Engert (:kaie) (inactive account) 2018-03-07 10:22:47 UTC
Created attachment 1405225 [details]
Daiki's suggested fix as a patch to certmonger

Comment 25 Rob Crittenden 2018-03-07 15:17:49 UTC
The patch works for me, thank you very much! It doesn't look like any changes to NSS are required.

Comment 31 Nikhil Dehadrai 2018-08-03 11:41:45 UTC
IPA version: ipa-server-4.6.4-3.el7.x86_64
Certmonger: certmonger-0.78.4-3.el7.x86_64

Verified that the sanity tests required for verifying this bug are run successfully.

No errors are observed when test run for ipa-getcert are run as regression for latest version.

Thus marking the status of bug to Verified, based on these observations.

Comment 33 Nikhil Dehadrai 2018-08-03 11:46:44 UTC
(In reply to Nikhil Dehadrai from comment #31)
> IPA version: ipa-server-4.6.4-3.el7.x86_64
> Certmonger: certmonger-0.78.4-3.el7.x86_64
> 
> Verified that the sanity tests required for verifying this bug are run
> successfully.
> 
> No errors are observed when test run for ipa-getcert are run as regression
> for latest version.
> 
> Thus marking the status of bug to Verified, based on these observations.

certmonger version: certmonger-0.78.4-8.el7.x86_64

Comment 35 errata-xmlrpc 2018-10-30 07:44:03 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, 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-2018:3018


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