Thank you @sscarduzio
I tried to follow the documentation but I have a problem in metricbeat side.
First, I generated self signed .jks key for a my private network host server (elastic.lan) using keytool
keytool -keypasswd readonlyrest -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass readonlyrest -validity 3650 -keysize 2048 -dname "cn=elastic.lan"
then I added to elasticserach.yml
and everything is working well when I tested it on browser or with curl command.
For metricbeat side, I extracted from .jks file the ceritficate and the key files using these commands
keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12 -deststoretype PKCS12
openssl pkcs12 -in keystore.p12 -nokeys -out cert.crt
openssl pkcs12 -in keystore.p12 -nocerts -nodes -out key.key
and copied them to my client server and edited metricbeat.yml
# Array of hosts to connect to.
Metricbeat was running but I get this error on log file
ERR Connecting error publishing events (retrying): Get https://elastic.lan:9200: x509: certificate signed by unknown authority
I know that I didn’t have a signed certificate from a certificate authority, is this the only problem or there is a messing up on my configuration ? If it is, how can I solve it ?