Create an SSL-authenticated DSP connection to Kafka
To get data from an Apache Kafka or Confluent Kafka broker into a data pipeline in Splunk Data Stream Processor (DSP), you must first create a connection. You can then use the connection in the Kafka source function to get data from Kafka into a DSP pipeline. If you have a Universal license, you can also use the connection in the Send to Kafka sink function to send data from DSP to a Kafka topic. See Licensing for the Splunk Data Stream Processor.
To protect your data, create a connection that uses the SSL Connector for Kafka. This connector supports two-way SSL authentication where the client and server authenticate each other using the SSL/TLS protocol.
If you're using the data for testing purposes in a secure internal environment, you can choose to create an unauthenticated connection that involves less overhead. See Create an unauthenticated DSP connection to Kafka for information about creating an unauthenticated connection.
Prerequisites
Before you can create an SSL-authenticated Kafka connection, you must have the following:
- At least one Kafka server that has SSL enabled and is running one of the following Kafka versions:
- Apache Kafka version 1.0 or higher
- Confluent Kafka version 3.0 or higher
- A Java keystore and truststore on each Kafka server with all certificates signed by a Certificate Authority (CA).
- A client private key, a client certificate, and the CA certificate used to sign the client certificate.
If you haven't yet created a Kafka client keystore to interact with your SSL-enabled Kafka server, follow the instructions on this page to create a Kafka client keystore and then extract the key and certificates in the format required for the Kafka SSL connection.
If you already have a Kafka client keystore where the RSA algorithm was used to generate the key/certificate pair, and the client certificate was signed by the same CA certificate used to sign the server certificate, then skip to the Export the key and certificates in PEM format and Create the SSL-authenticated Kafka connection in DSP sections on this page.
Create the client keystore
- From a command line interface, use the Java keytool command to create the client keystore.
keytool -keystore client.keystore.jks -alias localhost -validity 365 -genkey -keyalg RSA
- When prompted, set a password and enter some optional metadata for the keystore. You can set any password and metadata. You can choose to leave the metadata fields blank.
After entering the required information, a client.keystore.jks file is saved in your directory.
Sign the client certificate with a CA certificate
Sign the client certificate with the same CA certificate you used to sign the Kafka server certificate in the server keystore file. In this example, the CA certificate is in PEM format in a file named ca-cert, and the certificate starts with -----BEGIN CERTIFICATE-----
. The CA key is in PEM format in a file named ca-key, and the key starts with -----BEGIN ENCRYPTED PRIVATE KEY-----
.
- Export the client certificate so that it can be signed.
keytool -keystore client.keystore.jks -alias localhost -certreq -file cert-file
- Sign the client certificate with the CA certificate. When running this command, replace
<ca-password>
with the passphrase for the CA key.openssl x509 -req -CA ca-cert -CAkey ca-key -in cert-file -out cert-signed -days 365 -CAcreateserial -passin pass:<ca-password>
- Add the CA certificate to the keystore.
keytool -keystore client.keystore.jks -alias CARoot -import -file ca-cert
- Add the signed client certificate to the keystore.
keytool -keystore client.keystore.jks -alias localhost -import -file cert-signed
Export the key and certificates in PEM format
Export the signed client certificate, the CA certificate that was used to sign it, and the client private key from your keystore. You need to upload these exported files to DSP when creating a Kafka SSL connection.
- If your keystore is not already in PKCS12 (.p12) format, then convert it to that format. Make sure to use the same password for both the original keystore and the converted keystore. If you created your keystore based on the instructions in this topic, then you need to convert your keystore from JKS (.jks) format to PKCS12 (.p12) format using the following command.
keytool -importkeystore -srckeystore client.keystore.jks -destkeystore client.keystore.p12 -srcstoretype jks -deststoretype pkcs12
- Export the client private key unencrypted in PEM format, and convert it to RSA format. Save the formatted private key to the file privkey.pem. When running the following command, replace
<keystore-password>
with the password for your keystore.openssl pkcs12 -in client.keystore.p12 -nocerts -nodes -passin pass:<keystore-password> | openssl rsa -out privkey.pem
- Export the certificates to the file certs.pem. When running the following command, replace
<keystore-password>
with the password for your keystore.openssl pkcs12 -in client.keystore.p12 -nokeys -out certs.pem -passin pass:<keystore-password>
- Copy the signed client certificate and the CA certificate into separate files:
- Open the certs.pem file in a text editor, and then copy the signed client certificate into a new text file and save it. If you created your keystore and certificates based on the instructions in this topic, the signed client certificate is labeled as
friendlyName: localhost
. - From the certs.pem file, copy the CA certificate into a new text file and save it. If you created your keystore and certificates based on the instructions in this topic, the CA certificate is labeled as
friendlyName: CAroot
.
- Open the certs.pem file in a text editor, and then copy the signed client certificate into a new text file and save it. If you created your keystore and certificates based on the instructions in this topic, the signed client certificate is labeled as
Create the SSL-authenticated Kafka connection in DSP
Now that you have the required certificates and keys, create the Kafka connection in DSP.
- From the Data Stream Processor home page, click Data Management and then select the Connections tab.
- Click Create New Connection.
- Select SSL Connector for Kafka and then click Next.
- Complete the following fields:
Field Description Connection Name A unique name for your connection. Description (Optional) A description of your connection. Kafka Brokers A comma-separated list of your Kafka brokers. You must enter at least one broker. Client Private Key The file containing the client private key, beginning with -----BEGIN RSA PRIVATE KEY-----
and ending with-----END RSA PRIVATE KEY-----
. This file is created as privkey.pem during step 2 of Export the key and certificates in PEM format.Client Certificate The file containing the client certificate, beginning with -----BEGIN CERTIFICATE-----
and ending with-----END CERTIFICATE-----
. This file is created using the localhost certificate during step 4a of Export the key and certificates in PEM format.CA or Kafka Server Cert The file containing the original CA certificate. You can also use the file that is created using the CAroot certificate during step 4b of Export the key and certificates in PEM format. Kafka properties (Optional) Enter any consumer properties by which you want to delimit your data. To enter more than one property, click Add input for every new property you want to add. The Kafka source and sink functions that use this connection automatically set a list of Kafka properties that can't be overwritten. See the Kafka properties set by DSP section on this page.
Any credentials that you upload are transmitted securely by HTTPS, encrypted, and securely stored in a secrets manager.
- Click Save.
If you're editing a connection that's being used by an active pipeline, you must reactivate that pipeline after making your changes. When you reactivate a pipeline, you must select where you want to resume data ingestion. See Using activation checkpoints to activate your pipeline in the Use the Data Stream Processor manual for more information.
You can now use your connection in a Kafka source function at the start of your data pipeline to get data from Kafka, or in a Send to Kafka sink function at the end of your pipeline to send data to Kafka.
- For instructions on how to build a data pipeline, see the Building a pipeline chapter in the Use the manual.
- For information about the source function, see Get data from Kafka in the Function Reference manual.
- For information about the sink function, see Send data to Kafka in the Function Reference manual.
Kafka properties set by DSP
When using the SSL Connector for Kafka, the Kafka and Send to Kafka functions automatically set the following Kafka properties:
ssl.truststore.location=/local/path/to/kafka.client.truststore.jks ssl.truststore.password=<randomized-password> ssl.keystore.location=/local/path/to/kafka.client.keystore.jks ssl.keystore.password=<randomized-password> ssl.key.password=<randomized-password> ssl.keystore.type=JKS ssl.truststore.type=JKS security.protocol=SSL
You can't overwrite any of the properties in this list when connecting to Kafka using SSL.
Connecting Kafka to your DSP pipeline as a data destination | Create an unauthenticated DSP connection to Kafka |
This documentation applies to the following versions of Splunk® Data Stream Processor: 1.2.0, 1.2.1-patch02, 1.2.1, 1.2.2-patch02, 1.2.4, 1.2.5
Feedback submitted, thanks!