Skip to content

8359956: Support algorithm constraints and certificate checks in SunX509 key manager #25016

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

Closed
wants to merge 29 commits into from

Conversation

artur-oracle
Copy link
Member

@artur-oracle artur-oracle commented May 2, 2025

SunX509 key manager should support the same certificate checks that are supported by PKIX key manager.

Effectively there should be only 2 differences between 2 key managers:

  • PKIX supports multiple key stores through KeyStore.Builder interface while SunX509 supports only a single keystore.
  • SunX509 caches its whole key store on initialization thus improving performance. This means that subsequent modifications of the KeyStore have no effect on SunX509 KM, unlike PKIX .

SUNX509 KeyManager performance before the change
Benchmark (resume) (tlsVersion) Mode Cnt Score Error Units
SSLHandshake.doHandshake true TLSv1.2 thrpt 15 19758.012 ± 758.237 ops/s
SSLHandshake.doHandshake true TLS thrpt 15 1861.695 ± 14.681 ops/s
SSLHandshake.doHandshake false TLSv1.2 thrpt 15 1186.962 ± 12.085 ops/s
SSLHandshake.doHandshake false TLS thrpt 15 1056.288 ± 7.197 ops/s

SUNX509 KeyManager performance after the change
Benchmark (resume) (tlsVersion) Mode Cnt Score Error Units
SSLHandshake.doHandshake true TLSv1.2 thrpt 15 20954.399 ± 260.817 ops/s
SSLHandshake.doHandshake true TLS thrpt 15 1813.401 ± 13.917 ops/s
SSLHandshake.doHandshake false TLSv1.2 thrpt 15 1158.190 ± 6.023 ops/s
SSLHandshake.doHandshake false TLS thrpt 15 1012.988 ± 10.943 ops/s


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8360289 to be approved

Issues

  • JDK-8359956: Support algorithm constraints and certificate checks in SunX509 key manager (Enhancement - P4)
  • JDK-8360289: Support algorithm constraints and certificate checks in SunX509 key manager (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25016/head:pull/25016
$ git checkout pull/25016

Update a local copy of the PR:
$ git checkout pull/25016
$ git pull https://git.openjdk.org/jdk.git pull/25016/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25016

View PR using the GUI difftool:
$ git pr show -t 25016

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25016.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 2, 2025

👋 Welcome back abarashev! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented May 2, 2025

@artur-oracle 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:

8359956: Support algorithm constraints and certificate checks in SunX509 key manager

Reviewed-by: mullan

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 107 new commits pushed to the master branch:

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 master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented May 2, 2025

@artur-oracle The following labels will be automatically applied to this pull request:

  • core-libs
  • net
  • security

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.

@openjdk openjdk bot added security security-dev@openjdk.org core-libs core-libs-dev@openjdk.org net net-dev@openjdk.org labels May 2, 2025
@artur-oracle artur-oracle marked this pull request as ready for review May 12, 2025 16:07
@openjdk openjdk bot added the rfr Pull request is ready for review label May 12, 2025
@mlbridge
Copy link

mlbridge bot commented May 12, 2025

@haimaychao
Copy link
Contributor

haimaychao commented May 13, 2025

It is nice to refactor the common code for algorithm constraints checking into a new class, X509KeyManagerConstraints.java, used by both SunX509KeyManagerImpl and X509KeyManagerImpl. However, it looks like a new system property, "jdk.tls.keymanager.disableConstraintsChecking", is introduced, and it will affect both SunX509KeyManagerImpl and X509KeyManagerImpl. Should the property be a switch for SunX509 KeyManager, not a general toggle for all KeyManager? Avoiding its misuse for X509KeyManagerImpl that may lead to disable the existing RFC compliant algorithm constraints checking? It might be preferable to keep the property logic in SunX509KeyManagerImpl (not in the common code).

@artur-oracle
Copy link
Member Author

artur-oracle commented May 13, 2025

It is nice to refactor the common code for algorithm constraints checking into a new class, X509KeyManagerConstraints.java, used by both SunX509KeyManagerImpl and X509KeyManagerImpl. However, it looks like a new system property, "jdk.tls.keymanager.disableConstraintsChecking", is introduced, and it will affect both SunX509KeyManagerImpl and X509KeyManagerImpl. Should the property be a switch for SunX509 KeyManager, not a general toggle for all KeyManager? Avoiding its misuse for X509KeyManagerImpl that may lead to disable the existing RFC compliant algorithm constraints checking? It might be preferable to keep the property logic in SunX509KeyManagerImpl (not in the common code).

@haimaychao Thanks for looking into it! Yes, it will disable constraints checking for both key managers and I did it this way on purpose. I think it will be simpler and less confusing to the end users. This system property is off by default and my assumption is that if end users want to disable KM algorithm constraints checking they would expect it to be disabled system-wide.
Making this toggle SunX509-specific is a trivial change if we have a consensus on this.

@seanjmullan What do you think?

@artur-oracle
Copy link
Member Author

/issue add JDK-8170706

@openjdk
Copy link

openjdk bot commented May 15, 2025

@artur-oracle
Adding additional issue to issue list: 8170706: Support algorithm constraints in SunX509 key manager.

Comment on lines 237 to 238
System.setProperty(
"jdk.tls.SunX509keymanager.certSelectionChecking", "false");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you instead just removed "RSA keySize < 1024" from the jdk.certpath.disabledAlgorithms security property - would this test still pass? This way you could still test the other parts of the cert selection code.

This same comment applies to other tests where you have set the jdk.tls.SunX509keymanager.certSelectionChecking property to false.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, good point! It works for this particular test but the same approach doesn't work for other tests because they either rely on TrustManager do the constraints checks or MD5 algorithm being blocks by TLSv1.3 spec.

@seanjmullan
Copy link
Member

/csr

@seanjmullan
Copy link
Member

Please create a CSR for the new system property.

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Jun 20, 2025
@openjdk
Copy link

openjdk bot commented Jun 20, 2025

@seanjmullan has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@artur-oracle please create a CSR request for issue JDK-8359956 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 18, 2025

@artur-oracle This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@artur-oracle artur-oracle requested a review from seanjmullan July 29, 2025 15:37
@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Jul 31, 2025
@artur-oracle
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 31, 2025

Going to push as commit e544cd9.
Since your change was applied there have been 114 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 31, 2025
@openjdk openjdk bot closed this Jul 31, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 31, 2025
@openjdk
Copy link

openjdk bot commented Jul 31, 2025

@artur-oracle Pushed as commit e544cd9.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@shqking
Copy link
Contributor

shqking commented Aug 1, 2025

Hi I found that test/jdk/javax/management/security/SecurityTest.java failed after this patch on both AArch64 and x86_64. Filed in https://bugs.openjdk.org/browse/JDK-8364495. I was wondering if you could help take a look at this issue? Thanks.

@artur-oracle
Copy link
Member Author

Hi I found that test/jdk/javax/management/security/SecurityTest.java failed after this patch on both AArch64 and x86_64. Filed in https://bugs.openjdk.org/browse/JDK-8364495. I was wondering if you could help take a look at this issue? Thanks.

Hi! It's already fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated net net-dev@openjdk.org security security-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

5 participants