Closed Bug 108097 Opened 25 years ago Closed 24 years ago

cmsutil pick the wrong cert to create a CMS signed message

Categories

(NSS :: Tools, defect, P1)

All
Solaris
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: alam, Assigned: julien.pierre)

References

Details

Attachments

(2 files, 2 obsolete files)

cmsutil failed to use the correct signing cert to generate the CMS signed message when I have dual key certs (one for signing and the other for encrypting) that have the same Nickname in the cert database. I tried to use "-u 4", but cmsutil still use the wrong certificate (the encrypting cert, instead of signing cert) to sign the message. As result, I get the following error in Communicator when trying to read the sign msg: The certificate is not approved for the attempted operation. Below comment is quoted from Ian McGreer: "The problem seems to be that cmsutil is using CERT_FindCertByNickname, which does not distinguish usage." Note: this bug is preventing me to run the smime automated test using dual key certs.
Assigned the bug to Julien.
Assignee: wtc → jpierre
Priority: -- → P1
Target Milestone: --- → 3.4
Antonio, Can you still run your tests manually without cmsutil fixed ?
I can only run my test with single certificate (dual-purpose cert), but not with dual-key certs (one for signing and one for encryption). Since the dual-key certs is the prefer way for the deployment purpose, I would like to run my test with dual-key certs instead of single cert.
I believe the fix for this is to use CERT_FindUserCertByUsage to look up the cert rather than CERT_FindCertByNickname.
Attached patch proposed patch for cmsutil (obsolete) — — Splinter Review
Patch to allow dual-key certs to work
I have attached a patch for this. I don't have a dual key cert to test with so I haven't had a chance to test it for that case. But it does work with my normal single-key cert - it looks the cert by nickname and usage for both signing and encrypting, finds it, and the messages verify/decrypt in Communicator. It also requires the CERT_FindUserCertByUsage symbol to be exported. I'm proposing that this should be done in both 3.3.2 and on the tip for 3.4.
Patch to export CERT_FindUserCertByUsage .
I have also attached the patch to nss.def for 3.3.2 . Ian, could you please review the code change to cmsutil ? Thanks.
The new exported symbol (CERT_FindUserCertByUsage) needs to be approved by Bob Relyea.
Comment on attachment 58813 [details] [diff] [review] proposed patch for cmsutil This brings up a good point - we should really have a QA test for creating dual-key certs and using them with cmsutil...
Attachment #58813 - Flags: review+
I have a dual-key cert to test the cmsutil. Indeed, this is required for the S/MIME automated test. Once this bug is marked fixed, I will started testing it with my dual-key cert.
Antonio, when you are done could you please give me the testcase, so I can also put this into the regular NSS QA?
Antonio, I have a debug version of my tool with the patch built for Solaris 2.8 in /u/jpierre/cmsutil . Make sure to also use the NSS shared libraries from that directory as they are required for the patched cmsutil due to the new exported symbol. Let me know if it works with dual-key certs.
Tried to run the following with dual-key certs using the cmsutil in /u/jpierre/cmsutil gave me the following error message: cat /u/alam/tle_sprat/ns/server/msg/test/tle/smime/messages/sectest/plaintext.in | perl smime.pl -S "Security Test's America Online Inc ID" -p "netscape" -d "/u/alam/tle_sprat/ns/server/msg/test/tle/smime/certdb/sectest" | mail sectest2@netscape.com ERROR: cannot add default SMIMEEncKeyPrefs attribute. cmsutil: problem signing: Certificate key usage inadequate for attempted operation. Segmentation Fault - core dumped ERROR: signature generation failed. The dual-key certs can be found in: /u/alam/tle_sprat/ns/server/msg/test/tle/smime/certdb/sectest Note: I have set the LD_LIBRARY_PATH to /u/jpierre/cmsutil: #env |grep LD_LIBRARY_PATH LD_LIBRARY_PATH=/u/jpierre/cmsutil
Antonio, I reproduced your problem and am looking into it. It seems that the way cmsutil is written right now, it expects a signing cert to also be usable for encrypion, and tries to set the encryption preferences using it, but it fails. I think I need to reset the encryption preferences. Did you try encrypting to a recipient that has a dual-key cert ? I tried -E sectest2@netscape.com but it doesn't seem that there is a proper encryption cert for it in your database.
I didn't added other people's cert in my database. Now I have added the sectest2 recipient cert into the db, and try to send a encrypted message to it, and it worked fine: cat /u/alam/tle_sprat/ns/server/msg/test/tle/smime/messages /sectest/plaintext.in | perl smime.pl -E "sectest2@netscape.com" -d "/u/alam/tle_sprat/ns/server/msg/test/tle/smime/certdb/sectest" | mail sectest2@netscape.com You can try again.
Attachment #58813 - Attachment is obsolete: true
Antonio, Please get the new cmsutil from /u/jpierre/cmsutil and try it. It should work with dual-key certs now for both signing and encrypting. I have attached a new patch with the change. Basically when signing, cmsutil was automatically trying to use the signing cert as encryption cert if the encryption cert was unspecified. This setting of an encryption cert was not needed in this case as no encryption was performed, so I have simply removed that code. I have verified that all the cases work both with single-key and dual-key certs. I still need Bob to approve the change to export CERT_FindCertByUsage .
I tried to sign a message with dual-key certs, and this time cmsutil didn't give me the error messages I describe above. But when I tried to retrieve the signed message from communicator 4.77, the sender's encrypting cert is NOT being added to the "Other People" in the local certdb. Note: I can't verify this on latest mozilla trunk build because of bug 105774. I will tried this on Outlook Express to see if it has the same problem.
Outlook Express 5.5 also has the same problem. The sender's encrypting cert is not being added to the local cert db.
OK. I guess that code was necessary after all to include the recipient's encryption certificate. But it needed to be patched to support dual-key certs. I'm attaching another patch. Please try the newly-updated version of cmsutil from /u/jpierre/cmsutil again. Thanks.
Attachment #59969 - Attachment is obsolete: true
Finally, it worked now. I can sign/encrpyt with dual-key certs, and the sender's encrypting cert is added into the certdb as well.
Ian, Could you please review the latest patch I attached ? It seems to work great for me and Antonio in NSS 3.3 . Can't get it to work in NSS 3.4 though - but then again even without this patch all I get with NSS 3.4 is core dumps.
I am checking this in to the tip as I'm now convinced the s/mime crashes I'm getting in 3.4 are unrelated - they happen regardless of this patch. I would like to also check it into the 3.3 branch, but there is a code freeze. Everything should work on the 3.4 branch once 113746 gets resolved. I will wait until it does to mark this defect fixed.
Depends on: 113746
Attachment #59978 - Flags: review+
Comment on attachment 59978 [details] [diff] [review] latest patch for dual-key cert support just showing my support for the patch :)
My understanding is that we plan to have mozilla switched to NSS 3.4 (pre-release) in mozilla0.9.8. So we should stop checking in mozilla-related fixes on the NSS 3.3 branch unless they are targeted mozilla0.9.7.
I discussed this with Antonio. He has private builds from Julien that allow him to run his test suite. cmsutil is still useful to test the mozilla s/mime implementation until it uses 3.4 at which point a 3.4 based cmsutil will have to be used. I'm fine with this interim solution as long as Antonio is.
113746 is not reproducible, so marking this resolved
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: