Skip to content

Conversation

@hugz6
Copy link

@hugz6 hugz6 commented Oct 3, 2025

Add TLS support

Adds TLS/SSL configuration for connecting to Kafka clusters.

Changes

  • Basic TLS support with enabled and insecureSkipVerify options
  • Custom root CA support via rootCAFile for private certificate authorities
  • mTLS support via clientCertFile and clientKeyFile
  • TLS for AWS MSK IAM authentication

Configuration

tlsConfig:
  enabled: true
  insecureSkipVerify: false
  rootCAFile: ~/certs/ca.crt
  clientCertFile: ~/certs/client.crt
  clientKeyFile: ~/certs/client.key

TLS is automatically enabled when using authentication: aws_msk_iam.

Testing

Tested with:

  • Plaintext connections
  • TLS with insecureSkipVerify
  • TLS with custom CA validation

mTLS implementation is included but not tested.

@gemini-code-assist
Copy link

Summary of Changes

Hello @hugz6, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances Kplay's security posture by integrating robust TLS support for Kafka connections. Users can now define TLS settings directly within their Kplay profiles, enabling encrypted communication with Kafka brokers. This feature includes options for enabling TLS and controlling certificate verification, making Kplay more adaptable to various secure Kafka environments, from production to development setups.

Highlights

  • TLS Configuration: Introduced new "tlsConfig" options in Kplay profiles to enable secure communication with Kafka brokers.
  • Certificate Verification Control: Added "insecureSkipVerify" option within "tlsConfig" for flexible certificate validation, useful for development or self-signed certificates.
  • Kafka Client Integration: Updated the internal Kafka client builder to dynamically apply TLS settings, ensuring secure connections are established when configured.
  • Documentation & Examples: Provided clear documentation in README.md and updated sample-config.yml with examples for enabling TLS.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces TLS support, which is a great security enhancement. The implementation is mostly solid, but I've found a critical regression related to AWS MSK IAM authentication where TLS is no longer automatically enabled, which would break existing user configurations. I've provided a code suggestion to fix this. Additionally, I've noted that the documentation in the README regarding this is now incorrect. Finally, I've suggested an improvement to make the TLS configuration more robust by allowing custom CAs and client certificates for production environments. Overall, good work on adding this important feature.

README.md Outdated
insecureSkipVerify: false # Skip certificate verification (default: false, use true for self-signed certs in dev)
```

**Note:** When using AWS MSK IAM authentication, TLS is automatically enabled and configured.

Choose a reason for hiding this comment

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

high

This note is currently incorrect. The changes in this pull request have introduced a regression where TLS is no longer automatically enabled for AWS MSK IAM authentication. This will break existing configurations for users relying on this implicit behavior. To align the documentation with the intended (and previous) behavior, the implementation should be fixed to automatically enable TLS when authentication: aws_msk_iam is used.

Comment on lines 122 to 127
if pr.TLSConfig != nil && pr.TLSConfig.Enabled {
tlsCfg = &t.TLSConfig{
Enabled: true,
InsecureSkipVerify: pr.TLSConfig.InsecureSkipVerify,
}
}

Choose a reason for hiding this comment

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

high

There's a regression here that breaks existing functionality. AWS MSK IAM requires TLS, but this logic no longer enables it automatically if tlsConfig isn't explicitly defined in the profile. Previously, TLS was implicitly enabled for MSK IAM. This change will break existing configurations that rely on this behavior.

To fix this, you should ensure TLS is enabled whenever auth == t.AWSMSKIAM, while still respecting any user-provided tlsConfig settings.

if (pr.TLSConfig != nil && pr.TLSConfig.Enabled) || auth == t.AWSMSKIAM {
	// TLS is required for AWS MSK IAM and is now being enabled automatically.
	tlsCfg = &t.TLSConfig{
		Enabled: true,
	}
	if pr.TLSConfig != nil {
		tlsCfg.InsecureSkipVerify = pr.TLSConfig.InsecureSkipVerify
	}
}

Comment on lines +42 to +44
cfg := &tls.Config{
InsecureSkipVerify: tlsConfig.InsecureSkipVerify,
}

Choose a reason for hiding this comment

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

medium

The current TLS implementation is a good first step, but it's limited as it only allows configuring InsecureSkipVerify. To make TLS support more robust and production-ready, consider extending tlsConfig and this function to support:

  • Custom Root CAs (RootCAs in tls.Config) for verifying server certificates signed by a private CA.
  • Client certificates (Certificates in tls.Config) for mutual TLS (mTLS) authentication.

This would greatly increase the security and flexibility of connecting to various Kafka setups.

@hugz6 hugz6 marked this pull request as draft October 3, 2025 12:38
@dhth
Copy link
Owner

dhth commented Oct 4, 2025

@hugz6 Thanks for your contribution.

I'll wait for you to mark the PR as ready for review before taking a look.
Could you also add a brief summary of the scenarios this change helps with?
And feel free to take the Gemini review with a grain of salt — as with most LLM-generated feedback.

@hugz6
Copy link
Author

hugz6 commented Nov 24, 2025

@hugz6 Thanks for your contribution.

I'll wait for you to mark the PR as ready for review before taking a look. Could you also add a brief summary of the scenarios this change helps with? And feel free to take the Gemini review with a grain of salt — as with most LLM-generated feedback.

Hi, sorry it took me a bit to come back to this PR, I was very busy. I tried to make it look clean even though I'm not very used to it. I hope it's okay. The goal of this PR is to allow the Kplay tool to work with TLS-secured Kafka clusters, which is very common in production. I'll let you review it, feel free to reach out if you have any questions.

@hugz6 hugz6 marked this pull request as ready for review November 24, 2025 00:37
@dhth
Copy link
Owner

dhth commented Nov 26, 2025

Hi, sorry it took me a bit to come back to this PR, I was very busy. I tried to make it look clean even though I'm not very used to it. I hope it's okay. The goal of this PR is to allow the Kplay tool to work with TLS-secured Kafka clusters, which is very common in production. I'll let you review it, feel free to reach out if you have any questions.

Thanks @hugz6. I will try to take a look at your changes on the weekend.

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.

2 participants