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
8259401: Add checking to jarsigner to warn weak algorithms used in signer’s cert chain #2042
Conversation
…gner’s cert chain
|
@haimaychao The following labels 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 lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
/label remove core-libs |
@AlanBateman |
/label remove compiler |
@haimaychao |
@@ -1401,6 +1401,35 @@ private void checkWeakSign(PrivateKey key) { | |||
} | |||
} | |||
|
|||
private String checkWeakKey(PublicKey key) { |
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.
Can this method be static?
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.
static added.
} | ||
} | ||
|
||
private String checkWeakAlg(String alg) { |
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.
Can this method be static?
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.
static added.
// weak algorithms are used, and provide warnings as needed. | ||
certStr.append("\n").append(tab) | ||
.append("Signature algorithm: ") | ||
.append(checkWeakAlg(sigalg)) |
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.
If the cert is trusted, I don't think we should print a warning if the signature algorithm is weak. Otherwise this will generate false warnings for SHA-1 roots which are not an issue. You should check the key size though. And you can still print the signature algorithm. You may need to move line 1489-1490 before this to first determine if the cert is trusted.
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.
Fixed to not check the signature algorithm for a trusted cert, and updated the test accordingly.
|
||
public static void main(String[] args) throws Exception { | ||
|
||
// root certificate using SHA1withRSA and 1024-bit key |
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.
It will be helpful to have these comments logged as debug messages with System.out
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.
comment messages added.
Thanks for your review, Sean and Rajan. I've updated the webrev with your comments. |
if (trustedCerts.contains(x509Cert)) { | ||
// If the cert is trusted, only check its key size, but not its | ||
// signature algorithm. This is because warning should not be | ||
// generated for SHA-1 roots which are not an issue. |
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.
SHA-1 is just a glitch in the long history at this very moment, and thus I think it's inappropriate to mention it in the source code. In my opinion, the general reason we don't check the signature is that we trust its origin anyway and we don't verify the signature at all (do we?). On the other hand, since its key is used to sign other certs, we need to make sure the key size is big enough so that no one else is able to recover the key and use it to sign other certs.
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.
Yes, I would remove the 2nd sentence that starts with "This is ...". There are plenty of references on the Internet which explain this, so no need to add much detail.
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.
Removed.
.append(rb.getString("COMMA")) | ||
.append(checkWeakKey(key)); | ||
|
||
certStr.append("\n").append(tab).append("["); |
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.
It's a little strange to leave the other half of the bracket (certStr.append("]");
on line 1568) outside the if-else block. Can you please move it inside? Of course you will have to duplicate them.
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'd prefer to keep it as is instead of duplicating the code in several places inside if block and else block.
Thanks for the review, Max. The comment about trusted cert's sigalg checking has been removed. |
@haimaychao 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 44 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@seanjmullan, @wangweij, @rhalade) but any other Committer may sponsor as well.
|
/integrate |
@haimaychao |
/sponsor |
@wangweij @haimaychao Since your change was applied there have been 44 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit c7e2174. |
The jarsigner tool currently provides warning associated with the signer’s cert when it uses weak algorithms, but not for the CA certs. This change is to process the signer’s cert chain to warn if CA certs use weak algorithms.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2042/head:pull/2042
$ git checkout pull/2042