Skip to content

feat(kafka): add support for custom certificates #3321

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

Merged

Conversation

JanPetr
Copy link
Contributor

@JanPetr JanPetr commented Aug 7, 2025

Hello there!

In our company we use custom certificates to authenticate to our Kafka instances. Unfortunately PeerDB doesn't support uploading custom certificates for Kafka peers.

This PR adds the possibility. The PR reuses the same logic as used for Clickhouse peers.

Thank you for your work, review, feedback & eventual merge ❤️🙏

image

Hello there!

In our company we use custom certificates to authenticate to our Kafka instances. Unfortunately PeerDB doesn't support uploading custom certificates for Kafka peers.

This PR adds the possibility. The PR reuses the same logic as used for Clickhouse peers.

Thank you for your work, review, feedback & eventual merge ❤️🙏
@CLAassistant
Copy link

CLAassistant commented Aug 7, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@heavycrystal heavycrystal left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! Just a few minor comments

}
tlsSetting.Certificates = []tls.Certificate{cert}
}
if config.RootCa != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

consider setting up the root CAs with the shared.CreateTlsConfig helper

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to use it, but I've ran into the issue that for Kafka peer you may use multiple hosts split by comma. And shared.CreateTlsConfig() helper is designed to work with single host only.

So I can either refactor the shared.CreateTlsConfig() helper method to work with multiple hosts or keep it as it is. ClickHouse connector uses this approach as well.

What would you prefer? 🙏 Thank you for your time!

Copy link
Contributor

Choose a reason for hiding this comment

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

ah that's fair, I think it would be nice to refactor that function to accept a slice of hosts and then change both kafka and clickhouse to use. Not a blocker for merging though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, thanks @heavycrystal! So I'm keeping it as it is now and won't refactor.

@@ -75,7 +76,26 @@ func NewKafkaConnector(
kgo.WithLogger(kgoLogger(logger)),
)
if !config.DisableTls {
optionalOpts = append(optionalOpts, kgo.DialTLSConfig(&tls.Config{MinVersion: tls.VersionTLS13}))
tlsSetting := &tls.Config{MinVersion: tls.VersionTLS13}
Copy link
Contributor

@heavycrystal heavycrystal Aug 7, 2025

Choose a reason for hiding this comment

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

is TLS1.3 too bleeding edge? I'm not too familiar with the Kafka ecosystem but iirc Confluent may not always support TLS 1.3

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 lowered the version to tls.VersionTLS12

@JanPetr JanPetr requested a review from heavycrystal August 8, 2025 12:59
@iamKunalGupta iamKunalGupta merged commit 3fdb93d into PeerDB-io:main Aug 13, 2025
10 of 19 checks passed
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.

5 participants