Skip to content

Support SSL, mTLS and SASL for Kafka status events - #11

Merged
boma96 merged 2 commits into
mainfrom
feature/kafka-status-producer-security
Nov 26, 2026
Merged

boma96 merged 2 commits into
mainfrom
feature/kafka-status-producer-security

Conversation

@boma96

@boma96 boma96 commented Nov 23, 2026 •

Copy link
Copy Markdown

Summary

The Kafka producer that publishes task and workflow status events (conductor.message-publisher.type=kafka) always connected with PLAINTEXT, and there was no setting to change it. Status events, including task input and output, crossed the network unencrypted and the broker could not authenticate Conductor.

This PR passes Kafka producer settings through from conductor.message-publisher.kafka.producer.*, which enables:

Mode Settings
SSL security.protocol=SSL + truststore
mTLS security.protocol=SSL + truststore + keystore
SASL_SSL security.protocol=SASL_SSL, sasl.mechanism, sasl.jaas.config + truststore
SASL_PLAINTEXT security.protocol=SASL_PLAINTEXT, sasl.mechanism, sasl.jaas.config

Keystores and truststores can be PKCS12 or PEM files. kafka-clients stays at 3.9.1, which already supports all of this.

Example (mTLS with PEM files):

conductor.message-publisher.kafka.producer.security.protocol=SSL
conductor.message-publisher.kafka.producer.ssl.truststore.type=PEM
conductor.message-publisher.kafka.producer.ssl.truststore.location=/etc/conductor/kafka/ca.crt
conductor.message-publisher.kafka.producer.ssl.keystore.type=PEM
conductor.message-publisher.kafka.producer.ssl.keystore.location=/etc/conductor/kafka/client.pem

Changes

  • KafkaProperties: new producer map (Map<String, String>, so dotted keys like security.protocol stay intact).
  • KafkaEventServiceImpl:
    • Settings are built in one place: defaults (acks=all, client.id), then user settings, then bootstrapServers, then the serializers (which can't be overridden).
    • Validated at startup: invalid values, unreadable keystore/truststore files and inline PEM settings (ssl.keystore.key, ssl.keystore.certificate.chain, ssl.truststore.certificates) fail startup; unknown keys are logged as a warning. Secret values are never logged.
    • The producer is still created on the first event, so Kafka doesn't need to resolve at startup.
    • The producer moved from a static field to an instance field and is closed on shutdown, waiting at most 10 seconds so a Kafka outage can't hold up shutdown.
    • With no producer.* settings, behaviour is unchanged.
  • kafka/README.md: new "Kafka Status Events" section with examples per mode, PEM notes and openssl conversion commands.
  • adr/: new directory for architecture decision records; ADR-0001 records this decision and the alternatives considered.

Testing

  • KafkaEventServiceImplTest: 19 unit tests for settings building and validation.
  • KafkaSecurityContainerTest: 10 tests against a real apache/kafka:3.9.1 broker with one listener per mode (Testcontainers; skipped when Docker isn't available). Certificates are generated per run with keytool, so no keys are committed.
    • Delivery through the real service: SSL (PKCS12 and PEM truststores), mTLS (PKCS12 and PEM keystores), SASL_SSL (PLAIN and SCRAM-SHA-512), SASL_PLAINTEXT.
    • Rejection: no client certificate on the mTLS listener, wrong SASL password, untrusted broker certificate.
  • ./gradlew :conductor-kafka:spotlessCheck :conductor-kafka:test: all 53 module tests pass locally.

Not covered

  • The KAFKA_PUBLISH system task and the kafka-event-queue module build their own Kafka clients and are unchanged.
  • A renewed certificate or password takes effect only after a restart.

🤖 Generated with Claude Code

boma96 and others added 2 commits November 23, 2026 12:51
The Kafka status-event producer always connected with PLAINTEXT and
exposed no way to change it. Producer settings can now be passed through
under conductor.message-publisher.kafka.producer.*, which enables SSL,
mTLS, SASL_SSL and SASL_PLAINTEXT with PKCS12 or PEM files.

- Settings are validated at startup: invalid values, unreadable
  keystore/truststore files and inline PEM certificates fail startup;
  unknown keys are logged as a warning. Serializers can't be overridden.
- The producer is per service instance and closed on shutdown.
- kafka-clients stays at 3.9.1.
- Container tests run each mode end to end against apache/kafka:3.9.1
  with per-run keytool certificates, plus rejection cases.
- Documents the modes in kafka/README.md and records the decision in
  adr/0001-kafka-status-producer-security.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
KafkaProducer.close() waits indefinitely for unsent records, so a Kafka
outage during shutdown could hold up Conductor for up to
delivery.timeout.ms. Before the producer was closed on shutdown this
could not happen, so bound the wait to keep shutdown behaviour as it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@boma96
boma96 merged commit 17bbb56 into main Nov 26, 2026
11 of 12 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.

1 participant