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

KAFKA-13418: Support key updates with TLS 1.3 #11966

Merged
merged 6 commits into from
Mar 29, 2022

Conversation

ijuma
Copy link
Contributor

@ijuma ijuma commented Mar 29, 2022

Key updates with TLS 1.3 trigger code paths similar to renegotiation with TLS 1.2.
Update the read/write paths not to throw an exception in this case (kept the exception
in the handshake method).

With the default configuration, key updates happen after 2^37 bytes are encrypted.
There is a security property to adjust this configuration, but the change has to be
done before it is used for the first time and it cannot be changed after that. As such,
it is best done via a system test (filed KAFKA-13779).

To validate the change, I wrote a unit test that forces key updates and manually ran
a producer workload that produced more than 2^37 bytes. Both cases failed without
these changes and pass with them.

Note that Shylaja Kokoori attached a patch with the SslTransportLayer fix and hence
included them as a co-author of this change.

Co-authored-by: Shylaja Kokoori

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@ijuma
Copy link
Contributor Author

ijuma commented Mar 29, 2022

I intend to cherry-pick this change to the 3.2, 3.1 and 3.0 branches. cc @cadonna

@@ -1015,7 +1011,6 @@ public void testChannelCloseWhileProcessingReceives() throws Exception {

private String blockingRequest(String node, String s) throws IOException {
selector.send(createSend(node, s));
selector.poll(1000L);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed since it's redundant.

@@ -110,10 +110,6 @@ public void tearDown() throws Exception {
}
}

public SecurityProtocol securityProtocol() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was not used.

}
selector.send(createSend(node, node + "-" + 0));
selector.poll(0L);
server.renegotiate();
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this test fail with Java 8 where we use TLSv1.2 as default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I'll verify that it fails (Jenkins should show it) and update the test to be a TLS 1.3 test that only runs if Java is 11 or newer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@rajinisivaram rajinisivaram left a comment

Choose a reason for hiding this comment

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

@ijuma Thanks for the PR, LGTM

@ijuma
Copy link
Contributor Author

ijuma commented Mar 29, 2022

Various builds passed, there was one flake:

Build / JDK 17 and Scala 2.13 / kafka.admin.LeaderElectionCommandTest.[1] Type=Raft, Name=testElectionResultOutput, Security=PLAINTEXT

@ijuma ijuma merged commit 5aed178 into apache:trunk Mar 29, 2022
ijuma added a commit that referenced this pull request Mar 29, 2022
Key updates with TLS 1.3 trigger code paths similar to renegotiation with TLS 1.2.
Update the read/write paths not to throw an exception in this case (kept the exception
in the `handshake` method).

With the default configuration, key updates happen after 2^37 bytes are encrypted.
There is a security property to adjust this configuration, but the change has to be
done before it is used for the first time and it cannot be changed after that. As such,
it is best done via a system test (filed KAFKA-13779).

To validate the change, I wrote a unit test that forces key updates and manually ran
a producer workload that produced more than 2^37 bytes. Both cases failed without
these changes and pass with them.

Note that Shylaja Kokoori attached a patch with the SslTransportLayer fix and hence
included them as a co-author of this change.

Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>

Co-authored-by: Shylaja Kokoori
ijuma added a commit that referenced this pull request Mar 29, 2022
Key updates with TLS 1.3 trigger code paths similar to renegotiation with TLS 1.2.
Update the read/write paths not to throw an exception in this case (kept the exception
in the `handshake` method).

With the default configuration, key updates happen after 2^37 bytes are encrypted.
There is a security property to adjust this configuration, but the change has to be
done before it is used for the first time and it cannot be changed after that. As such,
it is best done via a system test (filed KAFKA-13779).

To validate the change, I wrote a unit test that forces key updates and manually ran
a producer workload that produced more than 2^37 bytes. Both cases failed without
these changes and pass with them.

Note that Shylaja Kokoori attached a patch with the SslTransportLayer fix and hence
included them as a co-author of this change.

Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>

Co-authored-by: Shylaja Kokoori
ijuma added a commit that referenced this pull request Mar 29, 2022
Key updates with TLS 1.3 trigger code paths similar to renegotiation with TLS 1.2.
Update the read/write paths not to throw an exception in this case (kept the exception
in the `handshake` method).

With the default configuration, key updates happen after 2^37 bytes are encrypted.
There is a security property to adjust this configuration, but the change has to be
done before it is used for the first time and it cannot be changed after that. As such,
it is best done via a system test (filed KAFKA-13779).

To validate the change, I wrote a unit test that forces key updates and manually ran
a producer workload that produced more than 2^37 bytes. Both cases failed without
these changes and pass with them.

Note that Shylaja Kokoori attached a patch with the SslTransportLayer fix and hence
included them as a co-author of this change.

Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>

Co-authored-by: Shylaja Kokoori
@cadonna
Copy link
Contributor

cadonna commented Mar 30, 2022

I intend to cherry-pick this change to the 3.2, 3.1 and 3.0 branches. cc @cadonna

@tombentley FYI

jeffkbkim pushed a commit to confluentinc/kafka that referenced this pull request May 12, 2022
Key updates with TLS 1.3 trigger code paths similar to renegotiation with TLS 1.2.
Update the read/write paths not to throw an exception in this case (kept the exception
in the `handshake` method).

With the default configuration, key updates happen after 2^37 bytes are encrypted.
There is a security property to adjust this configuration, but the change has to be
done before it is used for the first time and it cannot be changed after that. As such,
it is best done via a system test (filed KAFKA-13779).

To validate the change, I wrote a unit test that forces key updates and manually ran
a producer workload that produced more than 2^37 bytes. Both cases failed without
these changes and pass with them.

Note that Shylaja Kokoori attached a patch with the SslTransportLayer fix and hence
included them as a co-author of this change.

Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>

Co-authored-by: Shylaja Kokoori
jeffkbkim added a commit to confluentinc/kafka that referenced this pull request May 12, 2022
…cs-12-may-2022

* apache-kafka/3.0: (14 commits)
  fix: make sliding window works without grace period (#kafka-13739) (apache#11980)
  KAFKA-13794: Follow up to fix producer batch comparator (apache#12006)
  KAFKA-13794; Fix comparator of `inflightBatchesBySequence` in `TransactionManager` (apache#11991)
  KAFKA-13748: Do not include file stream connectors in Connect's CLASSPATH and plugin.path by default (apache#11908)
  KAFKA-13418: Support key updates with TLS 1.3 (apache#11966)
  KAFKA-13770: Restore compatibility with KafkaBasedLog using older Kafka brokers (apache#11946)
  KAFKA-13761: KafkaLog4jAppender deadlocks when idempotence is enabled (apache#11939)
  KAFKA-13759: Disable idempotence by default in producers instantiated by Connect (apache#11933)
  MINOR: Fix `ConsumerConfig.ISOLATION_LEVEL_DOC` (apache#11915)
  KAFKA-13750; Client Compatability KafkaTest uses invalid idempotency configs (apache#11909)
  ...
lmr3796 pushed a commit to linkedin/kafka that referenced this pull request Oct 30, 2023
…e#11966)

LI_DESCRIPTION=This may improve p99 inter-broker latency under TLS1.3

-- Original message --

Key updates with TLS 1.3 trigger code paths similar to renegotiation with TLS 1.2.
Update the read/write paths not to throw an exception in this case (kept the exception
in the `handshake` method).

With the default configuration, key updates happen after 2^37 bytes are encrypted.
There is a security property to adjust this configuration, but the change has to be
done before it is used for the first time and it cannot be changed after that. As such,
it is best done via a system test (filed KAFKA-13779).

To validate the change, I wrote a unit test that forces key updates and manually ran
a producer workload that produced more than 2^37 bytes. Both cases failed without
these changes and pass with them.

Note that Shylaja Kokoori attached a patch with the SslTransportLayer fix and hence
included them as a co-author of this change.

Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>

Co-authored-by: Shylaja Kokoori
lmr3796 pushed a commit to linkedin/kafka that referenced this pull request Oct 30, 2023
…e#11966)

LI_DESCRIPTION=This may improve p99 inter-broker latency under TLS1.3

-- Original message --

Key updates with TLS 1.3 trigger code paths similar to renegotiation with TLS 1.2.
Update the read/write paths not to throw an exception in this case (kept the exception
in the `handshake` method).

With the default configuration, key updates happen after 2^37 bytes are encrypted.
There is a security property to adjust this configuration, but the change has to be
done before it is used for the first time and it cannot be changed after that. As such,
it is best done via a system test (filed KAFKA-13779).

To validate the change, I wrote a unit test that forces key updates and manually ran
a producer workload that produced more than 2^37 bytes. Both cases failed without
these changes and pass with them.

Note that Shylaja Kokoori attached a patch with the SslTransportLayer fix and hence
included them as a co-author of this change.

Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>

Co-authored-by: Shylaja Kokoori
lmr3796 added a commit to linkedin/kafka that referenced this pull request Oct 31, 2023
…e#11966) (#485)

LI_DESCRIPTION=This may improve p99 inter-broker latency under TLS1.3

-- Original message --

Key updates with TLS 1.3 trigger code paths similar to renegotiation with TLS 1.2.
Update the read/write paths not to throw an exception in this case (kept the exception
in the `handshake` method).

With the default configuration, key updates happen after 2^37 bytes are encrypted.
There is a security property to adjust this configuration, but the change has to be
done before it is used for the first time and it cannot be changed after that. As such,
it is best done via a system test (filed KAFKA-13779).

To validate the change, I wrote a unit test that forces key updates and manually ran
a producer workload that produced more than 2^37 bytes. Both cases failed without
these changes and pass with them.

Note that Shylaja Kokoori attached a patch with the SslTransportLayer fix and hence
included them as a co-author of this change.

Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>

Co-authored-by: Shylaja Kokoori

Co-authored-by: Ismael Juma <ismael@juma.me.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants