Skip to content

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

Closed
@d31m07y1988

Description

@d31m07y1988

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 {

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions