Skip to content

Commit c08e096

Browse files
kafka_consumer: add ca certificate path option (DataDog#22602)
* Add option to pass ca certificate for oauth provider * add changelog * don't default to kafka ca certificate * remove default fallback * Update kafka_consumer/datadog_checks/kafka_consumer/data/conf.yaml.example Co-authored-by: Bryce Eadie <bryce.eadie@datadoghq.com> * Update kafka_consumer/assets/configuration/spec.yaml Co-authored-by: Bryce Eadie <bryce.eadie@datadoghq.com> --------- Co-authored-by: Bryce Eadie <bryce.eadie@datadoghq.com>
1 parent 45c4e5e commit c08e096

6 files changed

Lines changed: 24 additions & 0 deletions

File tree

kafka_consumer/assets/configuration/spec.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ files:
261261
Format: 'logicalCluster=lkc-xxxxx' or 'logicalCluster=lkc-xxxxx,identityPoolId=pool-xxxxx'
262262
value:
263263
type: string
264+
- name: tls_ca_cert
265+
enabled: false
266+
description: |
267+
Path to a CA certificate file used to verify the OIDC token endpoint's TLS certificate.
268+
This maps to librdkafka's `https.ca.location` property, which is separate from
269+
the broker connection's `ssl.ca.location` (configured through the top-level `tls_ca_cert`).
270+
value:
271+
type: string
272+
example: /path/to/oauth_ca_cert.pem
264273
- template: instances/tls
265274
- name: tls_crlfile
266275
description: |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Kafka consumer connects to oauth provider with ca certificate in custom path

kafka_consumer/datadog_checks/kafka_consumer/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def __get_authentication_config(self):
7979
)
8080
extras_parameters["sasl.oauthbearer.scope"] = self.config._sasl_oauth_token_provider.get("scope")
8181
extras_parameters["sasl.oauthbearer.extensions"] = self.config._sasl_oauth_token_provider.get("extensions")
82+
if self.config._sasl_oauth_tls_ca_cert:
83+
extras_parameters["https.ca.location"] = self.config._sasl_oauth_tls_ca_cert
8284

8385
for key, value in extras_parameters.items():
8486
# Do not add the value if it's not specified

kafka_consumer/datadog_checks/kafka_consumer/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ def __init__(self, init_config, instance, log) -> None:
8080
):
8181
self._tls_ca_cert = '/opt/datadog-agent/embedded/ssl/certs/cacert.pem'
8282

83+
self._sasl_oauth_tls_ca_cert = (
84+
self._sasl_oauth_token_provider.get("tls_ca_cert") if self._sasl_oauth_token_provider else None
85+
)
86+
8387
# Data Streams live messages
8488
self.live_messages_configs = instance.get('live_messages_configs', [])
8589

kafka_consumer/datadog_checks/kafka_consumer/config_models/instance.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class SaslOauthTokenProvider(BaseModel):
3838
client_secret: Optional[str] = None
3939
extensions: Optional[str] = None
4040
scope: Optional[str] = None
41+
tls_ca_cert: Optional[str] = None
4142
url: Optional[str] = None
4243

4344

kafka_consumer/datadog_checks/kafka_consumer/data/conf.yaml.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ instances:
217217
#
218218
# extensions: <EXTENSIONS>
219219

220+
## @param tls_ca_cert - string - optional - default: /path/to/oauth_ca_cert.pem
221+
## Path to a CA certificate file used to verify the OIDC token endpoint's TLS certificate.
222+
## This maps to librdkafka's `https.ca.location` property, which is separate from
223+
## the broker connection's `ssl.ca.location` (configured through the top-level `tls_ca_cert`).
224+
#
225+
# tls_ca_cert: /path/to/oauth_ca_cert.pem
226+
220227
## @param tls_verify - boolean - optional - default: true
221228
## Instructs the check to validate the TLS certificate(s) of the service(s).
222229
#

0 commit comments

Comments
 (0)