elasticsearch and the SSLHandshakeException in Java

In a single AWS-ec2 box, I have the springboot and elasticsearch jars.

I’m sending information to aws elasticsearch from a springboot application. Elastisearch and springboot jar both feature self-generated SSL certificates.

All restendpoints in the SB-jar function properly when accessed via HTTPS, but api calls that push data to elasticsearch produce the following error.

java.util.concurrent.ExecutionException: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Using the commands below, I imported certificates to the trust store.

keytool -genkeypair -alias localhost:9200 -keyalg RSA -validity 1000 -keysize 2048 -keystore /home/ec2-user/mycert.jks

keytool -export -alias localhost:9200 -keystore /home/ec2-user/mycert.jks -rfc -file /home/ec2-user/mycert1.jks

keytool -import -noprompt -trustcacerts -alias localhost:9200 -file /home/ec2-user/mycert1.jks -keystore /usr/lib/jvm/java-1.8.0-openjdk- -file mycert1.jks

However, the certificate problem continues. Tell me what certification I need to add, please.

Java 8 and elasticsearch 7.16.2 were also used.