Hearbeat and elasticsearch : x509: certificate signed by unknown authority

Hi,

I am trying to configure heartbeat with elasticsearch and kibana.
I am using version 6.7.1
I am receiving this error:

2019-04-29T11:34:10.127+0300 ERROR instance/beat.go:906 Exiting: fail to create the Elasticsearch loader: Error creating Elasticsearch client: Couldn't connect to any of the configured Elasticsearch hosts. Errors: [Error connection to Elasticsearch https://localhost:9200: Get https://localhost:9200: x509: certificate signed by unknown authority]

My heartbeat.yml file

output.elasticsearch:
hosts: "https://localhost:9200"
username: "admin"
password: "..."

heartbeat.config.monitors:
path: /etc/heartbeat/monitors.d/*.yml
reload.enabled: true
reload.period: 5s

heartbeat.monitors:

setup.kibana:
host: "http://localhost:5601"

ssl.verification_mode: none

Please properly format your config file use the </>-Button or backticks.

Please no passwords, even if it's localhost.

The ssl setting must be part of the elasticsearch output. Like:

output.elasticsearch:
  hosts: [".."]
  username: 'admin'
  password: '...'
  ssl.verification_mode: none

Can you reach that host when using curl or other clients? Have you verified that your certificate is in fact valid?