<a id="cp-vscode-connect-to-kafka"></a>

# Connect to a Kafka Cluster with Confluent for VS Code

Connect the Confluent for VS Code extension to an Apache Kafka® cluster to
browse topics, view schemas, and produce and consume messages from
inside your editor. The extension supports bootstrap-server connections with
Basic and API credential authentication, and an optional Schema Registry URL for
schema-aware operations. To connect to Confluent Platform, see
[Quick Start with Confluent Platform](vscode-quick-start.md#cp-vscode-quick-start).

## Prerequisites

- Confluent for VS Code: Follow the steps in [Installation](overview.md#vscode-installation)
- A running Kafka cluster

<!-- WARNING: THIS IS A SHARED FILE AND THE SOURCE IS LOCATED IN DOCS-COMMON. DO NOT ADD TO ANY OTHER REPO. -->

With Confluent for VS Code, you can connect to any Kafka API-compatible
cluster and any Confluent Schema Registry API-compatible server.

### Prerequisites

- VS Code: Follow the steps in [Installation](overview.md#vscode-installation).
- A Kafka-API compatible cluster: For more information see
  [Kafka Protocol Guide](https://kafka.apache.org/protocol.html)

### Create a new connection

1. Open VS Code.
2. In the VS Code Activity Bar, click the Confluent icon. If you have
   many extensions installed, you might need to click **…** to access
   **Additional Views** and select **Confluent** from the context menu.
3. In the Side Bar, click **+ Add New Connection** in the **Resources** section.
4. In the Command Palette, select **Enter manually**.

   The extension shows the **Create a new connection** page.

### Enter connection details

In the **Create a new connection** page, enter the details for your Kafka
cluster.

1. In the **General** section, enter the name of the connection and select the
   type of connection.
   - **Connection Name:** An easy-to-remember name to display in the
     **Resources** view.
   - **Connection Type:** In the dropdown, choose one of the following values:
     - Apache Kafka®
     - Confluent Cloud
     - Confluent Platform
     - Warpstream
     - Other
2. In the **Kafka Cluster** section, enter the bootstrap server and
   authentication details.

   Confluent for VS Code supports authenticating to Kafka with most of the
   commonly used SASL authentication mechanisms.
   - **Bootstrap Servers:** One or more `host:port` pairs to use for
     establishing the initial connection. For more than one server, use a
     comma-separated list.
   - **Authentication Type:** In the dropdown, choose one of the following
     values:
     - Username & Password (SASL/PLAIN)
     - API Credentials (SASL/PLAIN)
     - SASL/SCRAM (supports both `SCRAM-SHA-256` and `SCRAM-SHA-512`)
     - SASL/OAUTHBEARER
     - Kerberos (SASL/GSSAPI)

     #### NOTE
     To use Mutual TLS (mTLS) authentication, expand the
     **TLS Configuration** section and enter **Key Store** and
     **Trust Store** details.
     - **Verify Server Hostname:** Enable verification of the Kafka/Schema Registry host
       name matching the Distinguished Name (DN) in the broker’s certificate.
     - **Key Store Configuration:** Certificate used by Kafka/Schema Registry to
       authenticate the client. This is used to configure mutual TLS (mTLS) authentication.
       - **Path:** The path of the Key Store file.
       - **Password:** The store password for the Key Store file. Key Store
         password is not supported for PEM format.
       - **Key Password:** The password of the private key in the Key Store
         file.
       - **Type:** The file format of the Key Store file. Choose from PEM,
         PKCS12, or JKS.
     - **Trust Store Configuration:** Certificates for verifying SSL/TLS
       connections to Kafka/Schema Registry. This is required if Kafka/Schema Registry use a
       self-signed or a non-public Certificate Authority (CA).
       - **Path:** The path of the Trust Store file.
       - **Password:** The password for the Trust Store file. If a password
         is not set, the configured Trust Store file is used, but integrity
         checking of the Trust Store file is disabled. Trust Store password
         is not supported for PEM format.
       - **Key Password:** The password of the private key in the Trust Store
         file.
       - **Type:** The file format of the Trust Store file. Choose from
         PEM, PKCS12, or JKS.

       Confluent Cloud uses TLS certificates from
       [Let’s Encrypt](https://letsencrypt.org/), a trusted
       Certificate Authority (CA). Confluent Cloud doesn’t support self-managed
       certificates for TLS encryption. For more information, see
       [Manage TLS Certificates](/cloud/current/cp-component/clients-cloud-config.html#manage-tls-certificates).
3. In the **Schema Registry** section, enter the URL of the Schema Registry to use for
   serialization.
4. Click the **Authentication Type** dropdown and choose one of the following
   values:
   - Username & Password
   - API Credentials
   - OAuth

   To use mutual TLS (mTLS) authentication, expand the **TLS Configuration**
   section and enter **Key Store** and **Trust Store** details, as shown in the
   previous step.

### Test and save your connection

1. Click **Test** to test your connection.
2. Click **Save** to save the connection. You can save the connection
   configuration even if the test wasn’t successful.

   Confirm that your connected resources are displayed in the Side Bar.

## Related content

- [Quick Start with Confluent Platform](vscode-quick-start.md#cp-vscode-quick-start)
