Unable to access the kafka certs present in /home/site/wwwroot/ directory from azure web app(Spring boot application).

Snooka 0 Reputation points
2024-09-06T15:32:37.29+00:00

Hi Team,

We are trying deploy our Spring boot API Application which publishes records to Kafka topic. We placed Kafka Certs under /home/site/wwwroot/ and trying to access the Certs from this location in the code. It is able to access the file, but looks

When trying to access the file, we are able to access the filename but when we pass the jks certs file location in Kafka properties it is not able to fetch or read Certs. We are getting below Error in application.

Error Message: 2024-09-06T14:48:15.705765065Z: [INFO] 2024-09-06 14:48:15 - [reactor-http-epoll-3] INFO com.optum.sdoh.inbound.api.azureinboundapi.controller.SdohApiController:205 - ARVI:000ABCD::: - fa019482-0e64-470c-b1ec-a46f8c804b9c - Failed to publish to kafka topic.

WebApp: appsvc-sdohdt-dev-inbound-api

Logic used to fetch the file name:

String homePath = "/home";
String wwwrootPath = homePath + "/site/wwwroot";

File wwwrootDir = new File(wwwrootPath);
if (wwwrootDir.exists() && wwwrootDir.isDirectory()) {
    File[] files = wwwrootDir.listFiles();
    if (files != null) {
        for (File file : files) {
            System.out.println(file.getName());
        }
    }
} else {
    System.out.println("Directory does not exist.");
}

This is how we are setting the props with file location:

Properties props = new Properties();

props.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, "/home/site/wwwroot/truststore.jks")

props.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, "/home/site/wwwroot/keystore.jks")

Could you please help us to read the certs and publish messages to our Kafka topic.

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
904 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.