# Errors when enabling tls for APM and Elasticsearch kubernetes deployment

**URL:** https://discuss.elastic.co/t/errors-when-enabling-tls-for-apm-and-elasticsearch-kubernetes-deployment/263758
**Category:** Elasticsearch
**Tags:** elastic-stack-security
**Created:** [February 9, 2021, 3:44pm UTC](https://discuss.elastic.co/t/errors-when-enabling-tls-for-apm-and-elasticsearch-kubernetes-deployment/263758 "2021-02-09T15:44:02Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ciarand](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ciarand](https://discuss.elastic.co/u/ciarand)
#### Post date: [February 9, 2021, 3:44pm UTC](https://discuss.elastic.co/t/errors-when-enabling-tls-for-apm-and-elasticsearch-kubernetes-deployment/263758/1 "2021-02-09T15:44:02Z")

</div>

I am trying to set up tls in my kubernetes cluster that is using the elastic operator version 1.2. I was able to set up tls with Elasticsearch but I am having issues with the APM issue and don't what is the correct configuration for the APM service this is the current configuration.

I am trying to use the default configured certs by elastic but I get the following errors. In Elasticsearch `Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate`

Then in APM I get the error:

`pipeline/output.go:154 Failed to connect to backoff(elasticsearch(https://kibana-test-es-es-http.kibana-test.svc:9200)): Get "https://kibana-test-es-es-http.kibana-test.svc:9200": x509: certificate is valid for *.server.com, *.server.com, server.com, server.com, not kibana-test-es-es-http.kibana-test.svc`

APM.yaml

```
apiVersion: apm.k8s.elastic.co/v1
kind: ApmServer
metadata:
  name: kibana-test-apm-server
  namespace: kibana-test
spec:
  version: 7.10.2
  count: 1
  elasticsearchRef:
    name: kibana-test-es
  kibanaRef:
    name: kibana
  http:
    tls:
      certificate:
        secretName: kibana-test-es-es-http-certs-internal

```

Elasticsearch.yml

```
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: kibana-test-es
  namespace: kibana-test
spec:
  version: 7.10.2
  http:
    tls:
      certificate:
        secretName: kibana-test-es-es-http-certs-internal
  nodeSets:
    - name: default
      count: 3
      volumeClaimTemplates:
        - metadata:
            name: kibana-test-data
          spec:
            accessModes:
              - ReadWriteOnce
            resources:
              requests:
                storage: 10Gi
            storageClassName: ssd
      config:
        node.master: true
        node.data: true
        node.ingest: true
      podTemplate:
        spec:
          initContainers:
            - name: sysctl
              securityContext:
                privileged: true
              command: ["sh", "-c", "sysctl -w vm.max_map_count=262144"]
          containers:
            - name: elasticsearch
              # specify resource limits and requests
              resources:
                limits:
                  memory: 8Gi
                  cpu: 2
              env:
                - name: ES_JAVA_OPTS
                  value: "-Xms4g -Xmx4g"

```

Any idea why I am getting the errors, are the certificates not correctly configured or are they the incorrect ones to use?

---

<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 9, 2021, 3:44pm UTC](https://discuss.elastic.co/t/errors-when-enabling-tls-for-apm-and-elasticsearch-kubernetes-deployment/263758/2 "2021-03-09T15:44:17Z")

</div>

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