New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JDK-8290532: Adjust PKCS11Exception and handle more PKCS11 error codes #9555
Conversation
|
Webrevs
|
Btw. there are for most (all?) pkcs11 error/return codes good error descriptions available here http://docs.oasis-open.org/pkcs11/pkcs11-base/v3.0/os/pkcs11-base-v3.0-os.html (5.1 Function return values) ; should we maybe extend the exception message with a short text |
None of the 3 proposed error codes in this PR is in the standard PKCS#11 header files - two of them are vendor specific. For vendor specific error code, such direct mapping may be incorrect. As for CKR_COPY_PROHIBITED, I can't find any reference in your cited PKCS#11 spec above. Do you have other standard source for it? |
Hi Valerie, yes 0xCE534351L and 0xCE534352L are vendor specific but I added them because we got those (well the first one) in our jtreg test (please see JDK-8282538 for a detailled description, we got the same on RHEL9 instead of CentOS). So they are rather common errors on Linux I think and it would be nice to have them. |
I don't think it's worthwhile to add deprecated error codes. As for vendor specific error codes, I think they belong in a separate collection based on which vendor/PKCS#11 library is used. |
Okay makes sense then we leave the deprecated error code out. Do you have an idea how to easily get the vendor info of the lib ? A separate per vendor table sounds like a good idea. |
PKCS11Exception objects are constructed by PKCS#11 JNI code and vendor info is not readily available there. One easy compromise is to keep the hex error code value but append the string form when there is a match., i.e.
This way, even if the vendor is not NSS, but the original return value is still available for callers. |
…rror codes differently
Hi Valerie that sounds like a good idea, I adjusted the PR . |
// for vendor-defined values, check the enum for vendors and include | ||
// potential matches | ||
if ((errorCode & 0x80000000L) != 0) { | ||
// for unknown PKCS11 return values, just use hex as its string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: dup with line 201; can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Valerie I removed the comment line, also removed the '(' ')' at one place where they seem to be not needed.
Regarding "adresses the new output my needs" - ideally I would like to see some error text like the ones we find at http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/os/pkcs11-base-v2.40-os.html where the eror codes are explained.
But adding the (I think rather common) vendor errors is an improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For standard errors (except the deprecated one), the output is their name (e.g. CKR_xxx) instead of the value (0xABxxx hex). Vendor error code is vendor specific. It'd be nice if PKCS#11 API would provide an method for retrieving a String info based on error code, then callers won't have to refer to vendor's doc for the meaning.
Changes look good to me. Test result looks clean too.
Have you verified the new output and see if it addresses your need? I will also run the regression tests just to be safe. Thanks~ |
@MBaesken This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 110 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
|
/integrate |
Going to push as commit 07f0612.
Your commit was automatically rebased without conflicts. |
The issue https://bugs.openjdk.org/browse/JDK-8282538 gave an example of the following PKCS11 exception (see attached jtr files of that bug) :
.... Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: 0xCE534351
Unfortunately the error code 0xCE534351 is currently not in the RV/errorMap table of PKCS11Exception, That's why we get this
hex code and no more descriptive output, this could be improved.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9555/head:pull/9555
$ git checkout pull/9555
Update a local copy of the PR:
$ git checkout pull/9555
$ git pull https://git.openjdk.org/jdk pull/9555/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 9555
View PR using the GUI difftool:
$ git pr show -t 9555
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9555.diff