'Connect to confluent schema registry SSL configuration - unable to find valid certification path to requested target

How should it be configured the spring-cloud-schema-registry-client to communicate with Confluent Schema Registry on a secured manner using SSL truststore?

My configuration is the following:

spring:
  cloud:
    schema-registry-client:
      endpoint: https://confluent-schema-registry:443
      basic.auth.credentials.source: SASL_INHERIT
    stream:
      function:
        definition: functionConsumer;functionProducer
      kafka:
        binder:
          brokers: message-broker-url:9091
          configuration:
            security.protocol: SASL_SSL
            sasl:
              mechanism: SCRAM-SHA-512
              jaas.config: org.apache.kafka.common.security.scram.ScramLoginModule required username="username" password="password";
            ssl:
              truststore:
                location: classpath:cacerts
                password: password
      bindings:
        output-0:
          destination: output
          contentType: application/*+avro
        input-0:
          destination: input
          contentType: application/*+avro

Trying to produce a message to a channel, an javax.net.ssl.SSLHandshakeException is being thrown:

Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://confluent-schema-registry:443": PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source