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

KafkaProperties fail to build SSL properties when the bundle name is an empty string #43561

Closed
d31m07y1988 opened this issue Dec 18, 2024 · 0 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@d31m07y1988
Copy link

d31m07y1988 commented Dec 18, 2024

Problem on overriding kafka properties (https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java).

I have an application.yaml

 spring: 
   ssl:
    bundle:
      jks:
        mybundle:
          key:
            alias: ${MY_ALIAS}
          keystore:
            location: file:${MY_KEYFILE}
            password: ${MY_KEYPASSWORD}
            type: JKS
          trustore:
            location: file:${JAVA_KEYSTORE}
            password: ${JAVA_KEYSTORE_PWD}
            type: JKS
  kafka:
    security:
      protocol: SSL
    ssl:
      bundle: mybundle

If I need to set spring.kafka.ssl.bundle to null in application-local.yaml after starting it will always be empty string instead of null.

spring:
  kafka:
    security:
      protocol: PLAINTEXT
    ssl:
      bundle:

I think kafka properties should be modified to check bundle name is not emtpy.

if (getBundle() != null) => if (getBundle() != null && **getBundle().length > 0**)

in this part of KafkaProperties

public Map<String, Object> buildProperties(SslBundles sslBundles) {
	validate();
	Properties properties = new Properties();
	if (getBundle() != null) {
	properties.in(SslConfigs.SSL_ENGINE_FACTORY_CLASS_CONFIG)
		.accept(SslBundleSslEngineFactory.class.getName());
	properties.in(SslBundle.class.getName()).accept(sslBundles.getBundle(getBundle()));
	}
	else {
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 18, 2024
@philwebb philwebb changed the title Problem on overriding kafka properties KafkaProperties fail to build SSL properties when the bundle name is an empty string Dec 18, 2024
@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 18, 2024
@philwebb philwebb added this to the 3.3.x milestone Dec 18, 2024
@philwebb philwebb self-assigned this Dec 18, 2024
@philwebb philwebb modified the milestones: 3.3.x, 3.3.7 Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants