Skip to content
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

ZOOKEEPER-3806: TLS - dynamic loading for client trust/key store #1839

Closed
wants to merge 4 commits into from

Conversation

mathew-manu
Copy link
Contributor

ZooKeer currently has support for reloading the Quorum Truststore & Keystore automatically when the certificate files change in the filesystem without server restart (#680)

However, Reloading of key and trust store for ClientX509Util is not present; i.e., the server presented certs to the clients will not get reloaded automatically if the certificates in the filesystem change, short-lived certs requires the process restart.

Changes:

  • A new config property "zookeeper.client.certReload" is added, if it's true - ClientX509Util is reloaded automatically.

  • ZK uses an X509AuthenticationProvider which is backed by an X509TrustManager and an X509KeyManager to perform remote host certificate authentication. We need to update the X509AuthenticationProvider's TrustStore as part of the X509Util file-watcher.

  • Junit test case to verify the cert reload.

@mathew-manu
Copy link
Contributor Author

2 workflows awaiting approval (First-time contributor)
Can someone approve the workflows?

@mathew-manu
Copy link
Contributor Author

@symat Could you pls review this PR?
If certificates are updated on running clusters, server presented certificates to the clients are not refreshed automatically and requires process restarts. I think it's valuable to have this merged.

@li4wang
Copy link
Contributor

li4wang commented May 4, 2022

Agreed. This is a great feature to have.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

+1

Nice work

Copy link
Contributor

@symat symat left a comment

Choose a reason for hiding this comment

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

thank you for the contribution!
this is a very nice feature, I like the test too!!

Can you please add documentation for this new configuration near to the other ssl configs on our admin page? https://github.com/apache/zookeeper/blob/master/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md

using "new in 3.5.9"

@mathew-manu
Copy link
Contributor Author

thank you for the contribution! this is a very nice feature, I like the test too!!

Can you please add documentation for this new configuration near to the other ssl configs on our admin page? https://github.com/apache/zookeeper/blob/master/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md

using "new in 3.5.9"

@symat Updated the documentation with the new configuration.


* *client.certReload* :
(Java system property: **zookeeper.client.certReload**)
**New in 3.5.9:**
Copy link
Contributor

Choose a reason for hiding this comment

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

sorry  @mathew-manu , I asked you to document this as "new in 3.5.9", it should be 3.9.0. Can you change it? I can merge after that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the version to 3.9.0

}
}
}

public static ServerAuthenticationProvider getServerProvider(String scheme) {
return WrappedAuthenticationProvider.wrap(getProvider(scheme));
Copy link

Choose a reason for hiding this comment

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

THREAD_SAFETY_VIOLATION: Read/Write race. Non-private method ProviderRegistry.getServerProvider(...) indirectly reads without synchronization from auth.ProviderRegistry.initialized. Potentially races with write in method ProviderRegistry.reset().
Reporting because another access to the same memory occurs on a background thread, although this access may not.

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ProviderRegistry.reset() is only called from test.

Copy link
Contributor

@symat symat left a comment

Choose a reason for hiding this comment

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

thanks!! merging it now to master

@asfgit asfgit closed this in 7248644 May 6, 2022
@mathew-manu mathew-manu deleted the ZOOKEEPER-3806 branch May 6, 2022 21:32
@li4wang
Copy link
Contributor

li4wang commented May 19, 2022

@eolivelli @symat can we get this merged into 3.7 and 3.8 too? We are on 3.7 and it would be great if this can be supported in 3.7. Do we need to open a new JIRA? Please let me know if anything I can help. Thanks.

@symat
Copy link
Contributor

symat commented May 20, 2022

Hello @li4wang !
Normally we merge new features (like this one) only to master and we cherry-pick only the security and bug fixes to older branches. However, I see this commit to be valuable for the community and it doesn't change the default behavior. Also, I don't know when 3.9.0 will happen... so I'm open to have it backported to branch-3.8 and branch-3.7. @eolivelli what do you think?

If we would do that, then I think no new Jira is necessary, but we would need two new github PRs targeting branch-3.7 and branch-3.8. Also we would need a small PR on master, fixing the documentation about the version numbers (since when this feature is available... like "New in 3.7.2, 3.8.1, 3.9.0")

Just for your info: it is perfectly normal and legal (many of us actually do this) to build your own ZooKeeper version, based on a branch you are familiar with / tested before, adding only a few commits from later branches. Then use this in production. Building ZooKeeper is quite simple (use jdk8 and a relatively recent maven, then simply mvn clean install -DskipTests)

@eolivelli
Copy link
Contributor

I am +1 to port this to 3.8 and to 3.7.

Just for your info: it is perfectly normal and legal (many of us actually do this) to build your own ZooKeeper version, based on a branch you are familiar with / tested before, adding only a few commits from later branches. Then use this in production. Building ZooKeeper is quite simple (use jdk8 and a relatively recent maven, then simply mvn clean install -DskipTests)
This is "legal" but I must add that:

  • if you do this then you are not guaranteed that the project (PMC) verified the goodness of the release, so you should really know what are you doing (sometimes patches break the code and add side effects, that are fixed before releases while the community validates and blesses the release candidate).
  • if you go down this path, then ensure that all the tests are passing, especially using the JDK and OS that you are going to use in production

Every Apache product is meant to be consumed from the Source code, but ONLY using the Source Tarballs that have been approved with a formal and official VOTE.

@li4wang
Copy link
Contributor

li4wang commented May 23, 2022

That's great! Thanks @symat and @eolivelli. I will open a JIRA and create PRs for 3.7 and 3.8.

@li4wang
Copy link
Contributor

li4wang commented May 23, 2022

li4wang pushed a commit to li4wang/zookeeper that referenced this pull request May 23, 2022
ZooKeer currently has support for reloading the Quorum Truststore & Keystore automatically when the certificate files change in the filesystem without server restart (apache#680)

However, Reloading of key and trust store for **ClientX509Util** is not present; i.e., the server presented certs to the clients will not get reloaded automatically if the certificates in the filesystem change, short-lived certs requires the process restart.

Changes:

-  A new config property "zookeeper.client.certReload" is added, if it's true - ClientX509Util is reloaded automatically.

-  ZK uses an _X509AuthenticationProvider_ which is backed by an X509TrustManager and an X509KeyManager to perform _remote host certificate authentication_. We need to update the X509AuthenticationProvider's TrustStore as part of the X509Util file-watcher.
- Junit test case to verify the cert reload.

Author: Manu Mathew <manu.mathew@netapp.com>
Author: mathewmanu <manmathew@cs.stonybrook.edu>
Author: Manu Mathew <101424654+mathew-manu@users.noreply.github.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1839 from mathew-manu/ZOOKEEPER-3806
li4wang pushed a commit to li4wang/zookeeper that referenced this pull request May 23, 2022
ZooKeer currently has support for reloading the Quorum Truststore & Keystore automatically when the certificate files change in the filesystem without server restart (apache#680)

However, Reloading of key and trust store for **ClientX509Util** is not present; i.e., the server presented certs to the clients will not get reloaded automatically if the certificates in the filesystem change, short-lived certs requires the process restart.

Changes:

-  A new config property "zookeeper.client.certReload" is added, if it's true - ClientX509Util is reloaded automatically.

-  ZK uses an _X509AuthenticationProvider_ which is backed by an X509TrustManager and an X509KeyManager to perform _remote host certificate authentication_. We need to update the X509AuthenticationProvider's TrustStore as part of the X509Util file-watcher.
- Junit test case to verify the cert reload.

Author: Manu Mathew <manu.mathew@netapp.com>
Author: mathewmanu <manmathew@cs.stonybrook.edu>
Author: Manu Mathew <101424654+mathew-manu@users.noreply.github.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1839 from mathew-manu/ZOOKEEPER-3806
li4wang pushed a commit to li4wang/zookeeper that referenced this pull request May 24, 2022
ZooKeer currently has support for reloading the Quorum Truststore & Keystore automatically when the certificate files change in the filesystem without server restart (apache#680)

However, Reloading of key and trust store for **ClientX509Util** is not present; i.e., the server presented certs to the clients will not get reloaded automatically if the certificates in the filesystem change, short-lived certs requires the process restart.

Changes:

-  A new config property "zookeeper.client.certReload" is added, if it's true - ClientX509Util is reloaded automatically.

-  ZK uses an _X509AuthenticationProvider_ which is backed by an X509TrustManager and an X509KeyManager to perform _remote host certificate authentication_. We need to update the X509AuthenticationProvider's TrustStore as part of the X509Util file-watcher.
- Junit test case to verify the cert reload.

Author: Manu Mathew <manu.mathew@netapp.com>
Author: mathewmanu <manmathew@cs.stonybrook.edu>
Author: Manu Mathew <101424654+mathew-manu@users.noreply.github.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1839 from mathew-manu/ZOOKEEPER-3806
li4wang pushed a commit to li4wang/zookeeper that referenced this pull request May 24, 2022
Backporting ZOOKEEPER-4468 to branch-3.8

This is cherry-pick from apache#1839. This PR is the same as the apache#1839 on the master branch, only changing the documentation about the version numbers.

ZooKeer currently has support for reloading the Quorum Truststore & Keystore automatically when the certificate files change in the filesystem without server restart (apache#680)

However, Reloading of key and trust store for **ClientX509Util** is not present; i.e., the server presented certs to the clients will not get reloaded automatically if the certificates in the filesystem change, short-lived certs requires the process restart.

Changes:

-  A new config property "zookeeper.client.certReload" is added, if it's true - ClientX509Util is reloaded automatically.

-  ZK uses an _X509AuthenticationProvider_ which is backed by an X509TrustManager and an X509KeyManager to perform _remote host certificate authentication_. We need to update the X509AuthenticationProvider's TrustStore as part of the X509Util file-watcher.
- Junit test case to verify the cert reload.
li4wang pushed a commit to li4wang/zookeeper that referenced this pull request May 24, 2022
ZooKeer currently has support for reloading the Quorum Truststore & Keystore automatically when the certificate files change in the filesystem without server restart (apache#680)

However, Reloading of key and trust store for **ClientX509Util** is not present; i.e., the server presented certs to the clients will not get reloaded automatically if the certificates in the filesystem change, short-lived certs requires the process restart.

Changes:

-  A new config property "zookeeper.client.certReload" is added, if it's true - ClientX509Util is reloaded automatically.

-  ZK uses an _X509AuthenticationProvider_ which is backed by an X509TrustManager and an X509KeyManager to perform _remote host certificate authentication_. We need to update the X509AuthenticationProvider's TrustStore as part of the X509Util file-watcher.
- Junit test case to verify the cert reload.

Author: Manu Mathew <manu.mathew@netapp.com>
Author: mathewmanu <manmathew@cs.stonybrook.edu>
Author: Manu Mathew <101424654+mathew-manu@users.noreply.github.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1839 from mathew-manu/ZOOKEEPER-3806
li4wang pushed a commit to li4wang/zookeeper that referenced this pull request May 24, 2022
This is cherry-pick from apache#1839. This PR is the same as the apache#1839 on the master branch, only changing the documentation about the version numbers.

Signed-off-by: Li Wang <li4wang@gmail.com>
li4wang pushed a commit to li4wang/zookeeper that referenced this pull request May 24, 2022
ZooKeer currently has support for reloading the Quorum Truststore & Keystore automatically when the certificate files change in the filesystem without server restart (apache#680)

However, Reloading of key and trust store for **ClientX509Util** is not present; i.e., the server presented certs to the clients will not get reloaded automatically if the certificates in the filesystem change, short-lived certs requires the process restart.

Changes:

-  A new config property "zookeeper.client.certReload" is added, if it's true - ClientX509Util is reloaded automatically.

-  ZK uses an _X509AuthenticationProvider_ which is backed by an X509TrustManager and an X509KeyManager to perform _remote host certificate authentication_. We need to update the X509AuthenticationProvider's TrustStore as part of the X509Util file-watcher.
- Junit test case to verify the cert reload.

Author: Manu Mathew <manu.mathew@netapp.com>
Author: mathewmanu <manmathew@cs.stonybrook.edu>
Author: Manu Mathew <101424654+mathew-manu@users.noreply.github.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1839 from mathew-manu/ZOOKEEPER-3806
li4wang pushed a commit to li4wang/zookeeper that referenced this pull request May 24, 2022
This is cherry-pick from apache#1839. This PR is the same as the apache#1839 on the master branch, only changing the documentation about the version numbers.

Signed-off-by: Li Wang <li4wang@gmail.com>
li4wang pushed a commit to li4wang/zookeeper that referenced this pull request May 24, 2022
This is cherry-pick from apache#1839. This PR is the same as the apache#1839 on the master branch, only changing the documentation about the version numbers.

Signed-off-by: Li Wang <li4wang@gmail.com>

ZOOKEEPER-4546 Backport auto reloading client key/trust store to 3.8

This is cherry-pick from apache#1839. This PR is the same as the apache#1839 on the master branch, only changing the documentation about the version numbers.

Signed-off-by: Li Wang <li4wang@gmail.com>
li4wang pushed a commit to li4wang/zookeeper that referenced this pull request May 24, 2022
This is cherry-pick from apache#1839. This PR is the same as the apache#1839 on the master branch, only changing the documentation about the version numbers.

Signed-off-by: Li Wang <li4wang@gmail.com>
li4wang pushed a commit to li4wang/zookeeper that referenced this pull request May 24, 2022
This is cherry-pick from apache#1839. This PR is the same as the apache#1839 on the master branch, only changing the documentation about the version numbers.

Signed-off-by: Li Wang <li4wang@gmail.com>

ZOOKEEPER-4546 Backport auto reloading client key/trust store to 3.8

This is cherry-pick from apache#1839. This PR is the same as the apache#1839 on the master branch, only changing the documentation about the version numbers.

Signed-off-by: Li Wang <li4wang@gmail.com>
li4wang pushed a commit to li4wang/zookeeper that referenced this pull request May 24, 2022
This is cherry-pick from apache#1839. This PR is the same as the apache#1839 on the master branch, only changing the documentation about the version numbers.

Signed-off-by: Li Wang <li4wang@gmail.com>

ZOOKEEPER-4546 Backport auto reloading client key/trust store to 3.8

This is cherry-pick from apache#1839. This PR is the same as the apache#1839 on the master branch, only changing the documentation about the version numbers.

Signed-off-by: Li Wang <li4wang@gmail.com>
asfgit pushed a commit that referenced this pull request Jun 16, 2022
ZOOKEEPER-4545 Backport auto reloading client key/trust store to 3.7

This is cherry-pick from #1839. This PR is the same as the #1839 on the master branch, only changing the documentation about the version numbers.

Signed-off-by: Li Wang <li4wanggmail.com>

Author: Manu Mathew <manu.mathew@netapp.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes #1884 from li4wang/ZOOKEEPER-4545
anuragmadnawat1 pushed a commit to anuragmadnawat1/zookeeper that referenced this pull request Nov 2, 2022
ZooKeer currently has support for reloading the Quorum Truststore & Keystore automatically when the certificate files change in the filesystem without server restart (apache#680)

However, Reloading of key and trust store for **ClientX509Util** is not present; i.e., the server presented certs to the clients will not get reloaded automatically if the certificates in the filesystem change, short-lived certs requires the process restart.

Changes:

-  A new config property "zookeeper.client.certReload" is added, if it's true - ClientX509Util is reloaded automatically.

-  ZK uses an _X509AuthenticationProvider_ which is backed by an X509TrustManager and an X509KeyManager to perform _remote host certificate authentication_. We need to update the X509AuthenticationProvider's TrustStore as part of the X509Util file-watcher.
- Junit test case to verify the cert reload.

Author: Manu Mathew <manu.mathew@netapp.com>
Author: mathewmanu <manmathew@cs.stonybrook.edu>
Author: Manu Mathew <101424654+mathew-manu@users.noreply.github.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1839 from mathew-manu/ZOOKEEPER-3806
anuragmadnawat1 added a commit to anuragmadnawat1/zookeeper that referenced this pull request Nov 2, 2022
ZooKeer currently has support for reloading the Quorum Truststore & Keystore automatically when the certificate files change in the filesystem without server restart (apache#680)

However, Reloading of key and trust store for **ClientX509Util** is not present; i.e., the server presented certs to the clients will not get reloaded automatically if the certificates in the filesystem change, short-lived certs requires the process restart.

Changes:

-  A new config property "zookeeper.client.certReload" is added, if it's true - ClientX509Util is reloaded automatically.

-  ZK uses an _X509AuthenticationProvider_ which is backed by an X509TrustManager and an X509KeyManager to perform _remote host certificate authentication_. We need to update the X509AuthenticationProvider's TrustStore as part of the X509Util file-watcher.
- Junit test case to verify the cert reload.

Author: Manu Mathew <manu.mathew@netapp.com>
Author: mathewmanu <manmathew@cs.stonybrook.edu>
Author: Manu Mathew <101424654+mathew-manu@users.noreply.github.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1839 from mathew-manu/ZOOKEEPER-3806

Co-authored-by: Manu Mathew <manu.mathew@netapp.com>
anurag-harness pushed a commit to anurag-harness/zookeeper that referenced this pull request Jan 13, 2023
ZooKeer currently has support for reloading the Quorum Truststore & Keystore automatically when the certificate files change in the filesystem without server restart (apache#680)

However, Reloading of key and trust store for **ClientX509Util** is not present; i.e., the server presented certs to the clients will not get reloaded automatically if the certificates in the filesystem change, short-lived certs requires the process restart.

Changes:

-  A new config property "zookeeper.client.certReload" is added, if it's true - ClientX509Util is reloaded automatically.

-  ZK uses an _X509AuthenticationProvider_ which is backed by an X509TrustManager and an X509KeyManager to perform _remote host certificate authentication_. We need to update the X509AuthenticationProvider's TrustStore as part of the X509Util file-watcher.
- Junit test case to verify the cert reload.

Author: Manu Mathew <manu.mathew@netapp.com>
Author: mathewmanu <manmathew@cs.stonybrook.edu>
Author: Manu Mathew <101424654+mathew-manu@users.noreply.github.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1839 from mathew-manu/ZOOKEEPER-3806
anurag-harness added a commit to anurag-harness/zookeeper that referenced this pull request Jan 13, 2023
ZooKeer currently has support for reloading the Quorum Truststore & Keystore automatically when the certificate files change in the filesystem without server restart (apache#680)

However, Reloading of key and trust store for **ClientX509Util** is not present; i.e., the server presented certs to the clients will not get reloaded automatically if the certificates in the filesystem change, short-lived certs requires the process restart.

Changes:

-  A new config property "zookeeper.client.certReload" is added, if it's true - ClientX509Util is reloaded automatically.

-  ZK uses an _X509AuthenticationProvider_ which is backed by an X509TrustManager and an X509KeyManager to perform _remote host certificate authentication_. We need to update the X509AuthenticationProvider's TrustStore as part of the X509Util file-watcher.
- Junit test case to verify the cert reload.

Author: Manu Mathew <manu.mathew@netapp.com>
Author: mathewmanu <manmathew@cs.stonybrook.edu>
Author: Manu Mathew <101424654+mathew-manu@users.noreply.github.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1839 from mathew-manu/ZOOKEEPER-3806

Co-authored-by: Manu Mathew <manu.mathew@netapp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants