# Secure logstash connection to elasticsearch

**URL:** <https://discuss.elastic.co/t/secure-logstash-connection-to-elasticsearch/337369>\
**Category:** Logstash\
**Tags:** docker\
**Created:** [July 1, 2023, 1:22pm UTC](https://discuss.elastic.co/t/secure-logstash-connection-to-elasticsearch/337369 "2023-07-01T13:22:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeroWong](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/perowong/32/122917_2.png) [@PeroWong](https://discuss.elastic.co/u/PeroWong)\
**Post date:** [July 1, 2023, 1:22pm UTC](https://discuss.elastic.co/t/secure-logstash-connection-to-elasticsearch/337369/1 "2023-07-01T13:22:12Z")

</div>

I follow the tutorial([Install Elasticsearch with Docker | Elasticsearch Guide [8.8] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/8.8/docker.html#_prepare_the_environment)) creating certs in the docker-compose.yml services setup.

And I follow the guide to config logstash scure [Secure your connection to Elasticsearch | Logstash Reference [8.8] | Elastic](https://www.elastic.co/guide/en/logstash/current/ls-security.html)

```auto
output {
  elasticsearch {
    hosts => ["https://...] 
    cacert => "/usr/share/logstash/certs/ca/ca.crt"
  }
}

```

and mount the volum in the docker-compose.yml.

```auto
logstash:
    volumes:
      - certs:/usr/share/logstash/config/certs
...

```

When I start the logstash, it says `File does not exist or cannot be opened /usr/share/logstash/config/certs/ca/ca.crt`

But I enter the logstash container, the /usr/share/logstash/config/certs dir has been there.  
When I `cd /usr/share/logstash/config/certs`, it says "bash: cd:/usr/share/logstash/config/certs: Permission denied".

I guss this is the reason why it occurred the error that "File does not exist or cannot be opened /usr/share/logstash/config/certs/ca/ca.crt".

So, how could I solve this problem.

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [July 3, 2023, 10:12am UTC](https://discuss.elastic.co/t/secure-logstash-connection-to-elasticsearch/337369/2 "2023-07-03T10:12:26Z")

</div>

Hi @PeroWong,

Welcome to the community! It does look to me like a permissions issue as you say. Can you check the file permissions on the certs file to ensure logstash has access to the folder and file?

---

<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:** [July 31, 2023, 10:12am UTC](https://discuss.elastic.co/t/secure-logstash-connection-to-elasticsearch/337369/3 "2023-07-31T10:12:27Z")

</div>

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