Several question about SSL/TLS

@spinscale Thank you for your replay.

Firstly , I use x-pack complete basic auth.

Secondly,I execute bin/elasticsearch-certutil ca then elastic-stack-ca.p12 was generated with no password protected.

Thirdly, I execute bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12 then elastic-certificates.p12 was generated with no password protected.

Fourthly, I move elastic-stack-ca.p12 and elastic-certificates.p12 to config/certs and restart.

At last, I executecurl -k -u elastic:123456 -X GET https://MY_IP:9200 , and Elasticsearch show me a json.

My elasticsearch.yml was configured as mentioned above.

So, at this case, how can I generate certificates and connect with elasticsearch in java

sorry that I have so many question and waste your time
Hope for your answer,thank you again.