Bug 1074208

Summary: JSS certificate validation does not pass up exact error from NSS
Product: [Fedora] Fedora Reporter: Christina Fu <cfu>
Component: jssAssignee: Christina Fu <cfu>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 24CC: cfu, edewata, emaldona, jdennis, kwright, mharmsen, nkinder, rmeggins
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: jss-4.2.6-40.fc24 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1289335 (view as bug list) Environment:
Last Closed: 2017-08-08 11:45:33 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:
Bug Depends On:    
Bug Blocks: 1289335, 1289338    
Attachments:
Description Flags
jss-Added-verifyCertificate-method.patch
none
jss-Added-verifyCertificate-method2.patch
none
jss-Added-verifyCertificate-method.patch cfu: review+

Description Christina Fu 2014-03-08 22:39:07 UTC
Description of problem:
JSS's isCertValid() call does not pass up NSS's error code.  Such omission makes it impossible for the caller to identify what exact error(s) caused the cert to not validate.
isCertValid() and its JNI counterpart in PK11Finder.c:verifyCertificateNow() should pass up NSS's error codes from CERT_VerifyCertificateNow() 

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


How reproducible:
This problem was encountered when an SSL server cert was invalid due to its issuer dn containing mismatched encoding that causes self-test to fail in Dogtag CA startup.

Steps to Reproduce:
1. create an invalid ssl server cert
2. start dogtag ca
3. check debug log and you will not find any info on why it fails

Actual results:


Expected results:
debug log should contain info on why the cert fails the self-test

Additional info:

Comment 1 John Dennis 2014-03-09 19:27:38 UTC
FWIW the NSS error codes, especially with cert validation, are often worthless in helping to diagnose a problem. In some cases the error codes are genuinely misleading. My suggestion is to use the log info returned from CERT_VerifyCertificate or CERT_VerifyCertificateNow, the log info provides information on each aspect of the cert validation that failed. The log info also leaves something to be desired but it's way better than just the error return.

Comment 2 Fedora End Of Life 2015-05-29 11:11:55 UTC
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '20'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 20 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 3 Fedora End Of Life 2015-06-29 19:21:48 UTC
Fedora 20 changed to end-of-life (EOL) status on 2015-06-23. Fedora 20 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 4 Endi Sukma Dewata 2015-12-02 17:16:00 UTC
https://fedorahosted.org/pki/ticket/850

Comment 5 Endi Sukma Dewata 2015-12-08 23:02:16 UTC
Created attachment 1103739 [details]
jss-Added-verifyCertificate-method.patch

Comment 6 Christina Fu 2015-12-09 01:09:07 UTC
(In reply to Endi Sukma Dewata from comment #5)
> Created attachment 1103739 [details]
> jss-Added-verifyCertificate-method.patch

Two comments for now before I continue:
1. Could you explain how the following gives us more info to the error than before?
 JSS_throwMsgPrErr(env, JSS_EXCEPTION, "Invalid certificate");
I thought you were going to use PR_GetErrorText() from the example I pointed out in pkcs11/PK11KeyPairGenerator.c.  I have not tried it myself, but did you try it and did it not give you more error info?

2. It seems you changed the name of the method name
Java_org_mozilla_jss_CryptoManager_verifyCertificateNowNative
to
Java_org_mozilla_jss_CryptoManager_verifyCertificate
as we have gone over regarding "minimal changes", could you please refrain from making such change at this time?

Comment 7 Endi Sukma Dewata 2015-12-09 16:11:08 UTC
Created attachment 1103974 [details]
jss-Added-verifyCertificate-method2.patch

> 1. Could you explain how the following gives us more info to the error than
> before?
>  JSS_throwMsgPrErr(env, JSS_EXCEPTION, "Invalid certificate");

As discussed on IRC, the command will throw a JSSException containing the NSS error code and message, for example:

org.mozilla.jss.JSSException: Invalid certificate: (-8101) Certificate type not approved for application.

At least this is better than a simple boolean value returned by isCertValid().

> 2. It seems you changed the name of the method name
> Java_org_mozilla_jss_CryptoManager_verifyCertificateNowNative
> to
> Java_org_mozilla_jss_CryptoManager_verifyCertificate
> as we have gone over regarding "minimal changes", could you please refrain
> from making such change at this time?

As discussed on IRC, the change should not affect applications using JSS since the native method was originally private. And as a new public method, the "verifyCertificate" would be more user-friendly than "verifyCertificateNowNative".

However, the current patch apparently would change the behavior of both isCertValid() methods since they both call the C method verifyCertificateNow(). To limit the changes to the isCertValid() method that returns boolean, the new patch copies the C code from verifyCertificateNow() into the verifyCertificateNowNative() and only adds the exceptions there.

Comment 8 Endi Sukma Dewata 2015-12-09 17:17:33 UTC
Created attachment 1104028 [details]
jss-Added-verifyCertificate-method.patch

Added null checking in verifyCertificate().

Comment 9 Christina Fu 2015-12-09 22:54:02 UTC
Comment on attachment 1104028 [details]
jss-Added-verifyCertificate-method.patch

Overall it looks good provided tested to work.

As discussed over IRC, the isCertValid()'s were a bit convoluted to start with, and we will provide a better consolidated solution when we do the upstream merge and refactor.

Comment 10 Jan Kurik 2016-02-24 13:14:28 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 24 development cycle.
Changing version to '24'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora24#Rawhide_Rebase

Comment 11 Mike McCune 2016-03-28 22:23:55 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions

Comment 12 Fedora Update System 2016-05-19 20:55:01 UTC
jss-4.2.6-39.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-d3c8f022c5

Comment 13 Fedora Update System 2016-05-19 23:32:29 UTC
jss-4.2.6-40.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-c036afbe30

Comment 14 Fedora Update System 2016-05-21 01:31:41 UTC
jss-4.2.6-40.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-c036afbe30

Comment 15 Fedora Update System 2016-05-21 20:26:46 UTC
jss-4.2.6-40.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 16 Endi Sukma Dewata 2016-05-27 22:59:44 UTC
PKI was modified to utilize the new JSS functionality in the following commit:
* 2c73f1c2721021755d5753f07fa059a018ae9d7f

Comment 17 Fedora End Of Life 2017-07-25 18:38:32 UTC
This message is a reminder that Fedora 24 is nearing its end of life.
Approximately 2 (two) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 24. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '24'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 24 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 18 Fedora End Of Life 2017-08-08 11:45:33 UTC
Fedora 24 changed to end-of-life (EOL) status on 2017-08-08. Fedora 24 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.