This guide shows how to configure the CSID Secrets Provider for Vault to authenticate Kafka Connect to Vault using TLS client certificate authentication, using PEM-encoded files (no Java keystores).
We also explore a possible bug or major oversight in the current implementation that may prevent cert-based auth from working at all.
The plugin supports:
config.providers.vault.param.vault.auth.method=Certificate
Which triggers this code:
response = vault.auth().loginByCert();
This in turn delegates to the vault-java-driver
:
RestResponse restResponse = getRest()
.sslContext(config.getSslConfig().getSslContext())
.post();
This will only work correctly if the SslConfig
has been fully populated.
The SslConfig
supports:
.pemClientCertPath(String)
.pemClientKeyPath(String)
.pemTrustedCerts(String)
The CSID plugin parses your Kafka config using VaultConfigProviderConfig
. The only TLS-related setting it handles is:
this.verify = props.get("vault.ssl.verify.enabled");
(VaultConfigProviderConfig.java)
There is no support for vault.ssl.pem_cert_path
, pem_key_path
, or pem_trust_path
, so those values are never passed into SslConfig
, which means:
The Certificate auth method is effectively non-functional out-of-the-box
Unless the Vault client is picking up TLS settings from system properties or environment variables (which is undocumented), this is a major flaw.
To enable cert auth:
- Update
VaultConfigProviderConfig
to support:
public final String pemCertPath;
public final String pemKeyPath;
public final String pemTrustPath;
And read:
this.pemCertPath = props.get("vault.ssl.pem_cert_path");
this.pemKeyPath = props.get("vault.ssl.pem_key_path");
this.pemTrustPath = props.get("vault.ssl.pem_trust_path");
- Update
VaultConfigProvider
(or whereverSslConfig
is built) to pass these values:
SslConfig ssl = new SslConfig()
.pemClientCertPath(config.pemCertPath)
.pemClientKeyPath(config.pemKeyPath)
.pemTrustedCerts(config.pemTrustPath)
.verify(config.verify);
- Document these options in the README and include a working cert-auth example.
config.providers=vault
config.providers.vault.class=io.confluent.csid.config.provider.vault.VaultConfigProvider
# Vault server details
config.providers.vault.param.vault.address=https://vault.example.com
config.providers.vault.param.vault.auth.method=Certificate
config.providers.vault.param.vault.auth.mount=cert
# TLS authentication using PEM files
config.providers.vault.param.vault.ssl.pem_cert_path=/etc/kafka/secrets/client.crt # Client TLS certificate signed by Vault-trusted CA
config.providers.vault.param.vault.ssl.pem_key_path=/etc/kafka/secrets/client.key # Private key associated with the client certificate
config.providers.vault.param.vault.ssl.pem_trust_path=/etc/kafka/secrets/vault-ca.pem # CA certificate used to verify Vault server's TLS certificate
config.providers.vault.param.vault.ssl.verify=true # Enable TLS certificate validation (always true in production)
β οΈ These PEM settings will not work until the plugin is patched to pass them toSslConfig
.
The plugin clearly intends to support cert auth, but doesn't parse or pass the PEM-based TLS settings needed to make it work. This isn't just an omission β it may be a functional bug.
If you're integrating Vault with Kafka and need cert-based auth, you'll need to patch or fork the CSID plugin until this is addressed.
Issue has been opened: confluentinc/csid-secrets-providers#426
This other connector also exists: https://docs.lenses.io/latest/connectors/secret-providers/hashicorp-vault