Kibana - Unable to retrieve version information from Elasticsearch nodes. self signed certificate in certificate chain

For additional info, here all the commands/steps I took.

For configuring Elasticsearch:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
sudo apt-get install apt-transport-https
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
sudo apt-get update && sudo apt-get install elasticsearch kibana

Generated an enrollment token for Kibana and copied it but wasn't sure what to do with it

/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable kibana.service

Increased Elasticsearch timeout values and then started it

sudo systemctl start elasticsearch.service

Opened /etc/elasticsearch/elasticsearch.yml and changed the host ip:

network.host: 10.0.2.15

Verified node was running

root@ubuntu:~# curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic https://10.0.2.15:9200
Enter host password for user 'elastic':
{
  "name" : "ubuntu",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "Nw0yZgQaShugMnTcSGZUSA",
  "version" : {
    "number" : "8.1.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "3700f7679f7d95e36da0b43762189bab189bc53a",
    "build_date" : "2022-03-03T14:20:00.690422633Z",
    "build_snapshot" : false,
    "lucene_version" : "9.0.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

Next I moved onto Kibana instructions which say to generate an enrollment token for Kibana with the elasticsearch-create-enrollment-token tool and start Kibana and enter the enrollment token to securely connect Kibana with Elasticsearch.

I try to start Kibana with bin/kibana and kept getting this error message:

Unable to retrieve version information from Elasticsearch nodes. socket hang up

I found a fix which was to change in kibana.yml elasticsearch.hosts: ["http://10.0.2.15:9200"] to elasticsearch.hosts: ["https://10.0.2.15:9200"]. HTTP to HTTPS.

Tried starting Kibana and then I run into the problem described in the OP.