-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8257497: Update keytool to create AKID from the SKID of the issuing certificate as specified by RFC 5280 #2343
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
Conversation
|
👋 Welcome back hchao! A progress list of the required criteria for merging this PR into |
|
@haimaychao The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
|
@haimaychao This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. 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 381 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. ➡️ To integrate this PR with the above commit message to the |
|
@coffeys Thanks for the review! |
seanjmullan
left a comment
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.
I think it would be useful to add a test that checks that keytool now creates the AKID from the issuing CA's SKID. keytool -ext should be able to create a certificate with your own AKID, but you need to specify the OID and a hex-encoded string for the value. Check with @wangweij but I think you can probably enhance an existing test.
Unfortunately, SKID and AKID are currently added after all other extensions, therefore it will overwrite any SKID or AKID you explicitly provided. If you want to add your special SKID in the root CA cert, you'll need to move the SKID and AKID generations to the beginning the |
| .shouldContain("AuthorityKeyIdentifier") | ||
| .shouldContain("0000: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15") | ||
| .shouldContain("0010: 16 17 18 19") | ||
| .shouldHaveExitValue(0); |
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.
Or you can directly read the certificate and look at its extensions using some API.
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.
The current method serves the need to verify the accuracy of the AKID for this PR, and it looks straightforward to perceive I think. The API such as cert.getExtensionValue(KnownOIDs.AuthorityKeyID.value()), and new DerValue to getOctetString() could also be used.
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.
The 3 shouldContain lines cannot prove they appear in that order.
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.
These lines are from the output of the keytool -printcert command. If there may be a problem with the ordering, it would be worth the effort to look into -printcert. I've changed to use APIs to ease the ordering concern.
|
|
||
| byte[] signerSubjectKeyIdExt = ((X509Certificate)signerCert).getExtensionValue( | ||
| KnownOIDs.SubjectKeyID.value()); | ||
|
|
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.
How about pass in the KeyIdentifier instead of PublicKey akey into the createV3Extensions method? And you can calculated with
if (signerCert instanceof X509CertImpl) {
impl = (X509CertImpl) signerCert;
} else {
impl = new X509CertImpl(signerCert.getEncoded());
}
impl.getSubjectKeyId();
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.
Changed as suggested.
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.
Sorry, I should have been more verbose on my suggestion. I was thinking about passing in only the KeyIdentifier and not akey. After all both of them are for the same purpose and it's clear to consolidate to only one. If the cert has an SKID then use it, otherwise calculate one using new KeyIdentifier(akey). All these are done inside the doGenCert)() method. The createV3Extensions just add an AKID if the parameter is not null.
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.
Updated as suggested.
wangweij
left a comment
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.
LGTM.
|
Thanks for the review, Max! |
| PublicKey issuerPubKey = signerCert.getPublicKey(); | ||
|
|
||
| KeyIdentifier signerSubjectKeyId; | ||
| if (subjectPubKey.equals(issuerPubKey)) { |
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.
I think in most cases, this equality test will not work as there is no requirement for PublicKey to override Object.equals, so in most cases this will just check if they reference the same object. I suggest comparing the encoded bytes.
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.
Original logic using this equality test. Fixed as suggested.
seanjmullan
left a comment
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.
Looks good. However, I think you should change the title of the bug to be more descriptive, which will help for release notes, etc. How about: "Update keytool to create AKID from the SKID of the issuing certificate as specified by RFC 5280."
|
@seanjmullan Good idea, and updated the bug's title as suggested. Thanks for the review. |
|
/integrate |
|
@haimaychao Since your change was applied there have been 381 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 05301f5. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This change is made for compliance with RFC 5280 section 4.2.1.1 for Authority Key Identifier extension.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2343/head:pull/2343$ git checkout pull/2343