# Connecting Logstash To Elasticsearch via SSL (Docker Container)

**URL:** <https://discuss.elastic.co/t/connecting-logstash-to-elasticsearch-via-ssl-docker-container/353221>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security, docker\
**Created:** [February 14, 2024, 4:29am UTC](https://discuss.elastic.co/t/connecting-logstash-to-elasticsearch-via-ssl-docker-container/353221 "2024-02-14T04:29:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhiwakar\_Ravikumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dhiwakar_ravikumar/32/131318_2.png) [@Dhiwakar\_Ravikumar](https://discuss.elastic.co/u/Dhiwakar_Ravikumar)\
**Post date:** [February 14, 2024, 4:29am UTC](https://discuss.elastic.co/t/connecting-logstash-to-elasticsearch-via-ssl-docker-container/353221/1 "2024-02-14T04:29:50Z")

</div>

My environment consists of 2 docker containers, one running Logstash and another running Elasticsearch on the SAME host & SAME docker network.  
I am trying to setup SSL between the 2 of them (this is because Elasticsearch needs SSL and can be reached out to by sources outside the network, thus Logstash also needs to communicate with Elasticsearch via SSL). Since I’m testing this out I’m using self signed certificates.

I have been running into various issues as far as configuration is concerned, I only have 1 pair of SSL key & certificate which I’m using across my dev/test environment.

Here’s what my elasticsearch configuration looks like

```auto
[root@hdp100:~ (default)]$ docker exec -it elastic_default bash -c "cat /usr/share/elasticsearch/config/elasticsearch.yml"
    network.host: 0.0.0.0
    node.roles: [data, master]
    cluster.name: "docker-cluster"
    discovery.type: single-node
    # Enable security features
    xpack.security.enabled: true
    xpack.security.authc.realms.file.file1.order: 0
    xpack.security.http.ssl.enabled: true
    xpack.security.http.ssl.key: /usr/share/elasticsearch/config/security/logstore_server.key
    xpack.security.http.ssl.certificate: /usr/share/elasticsearch/config/security/logstore_server.crt

```

```auto

output {
  if [kubernetes] {
     if [kubernetes][labels][adcomponent] {
          elasticsearch {
           user => “test"
           password => “pass@word"
           hosts => ["https://ad-elastic:9200"]
           manage_template => false
           index => "kubernetes-logs-%{[kubernetes][labels][adcomponent]}-%{+yyyy.MM.dd}"
           ssl_enabled => true
           cacert => ["/usr/share/logstash/config/security/logparse_server.crt"]
         }
     }
     else {
        elasticsearch {
         user => “test"
         password => “pass@word"
         hosts => ["https://ad-elastic:9200"]
         manage_template => false
         index => "kubernetes-logs-kubernetes-%{+yyyy.MM.dd}"
         ssl_enabled => true
         cacert => ["/usr/share/logstash/config/security/logparse_server.crt"]
       }
     }
   }
}

```

I keep getting the following error in logstash, ad-elastic resolves to the IP of the docker container running elastic.

[2024-02-14T09:51:57,824][WARN][logstash.outputs.elasticsearch][main] Attempted to resurrect connection to dead ES instance, but got an error {:url=\>"[https://test:xxxxxx@ad-elastic:9200/](https://test:xxxxxx@ad-elastic:9200/)", :exception=\>LogStash::Outputs::Elasticsearch::HttpClient::Pool::HostUnreachableError, :message=\>"Elasticsearch Unreachable: [[https://ad-elastic:9200/](https://ad-elastic:9200/)][Manticore::UnknownException] Certificate for doesn't match any of the subject alternative names: [vm001.sre.test.dev, \*.sre.test.dev]"}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 13, 2024, 4:30am UTC](https://discuss.elastic.co/t/connecting-logstash-to-elasticsearch-via-ssl-docker-container/353221/2 "2024-03-13T04:30:01Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
