# Using own certificate

**URL:** <https://community.traefik.io/t/using-own-certificate/14310>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [April 29, 2022, 2:02pm UTC](https://community.traefik.io/t/using-own-certificate/14310 "2022-04-29T14:02:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![celcin](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@celcin](https://community.traefik.io/u/celcin)\
**Post date:** [April 29, 2022, 2:02pm UTC](https://community.traefik.io/t/using-own-certificate/14310/1 "2022-04-29T14:02:30Z")

</div>

I want to use my own certificate with traefik, unfortunately tls is not getting verified. The following error from traefik logs:  
dir structure as below

- docker-compose.yaml
- certs/tls.yml
- certs/dev.mydomain.com.crt
- certs/dev.mydomain.com.key

```auto
time="2022-04-29T13:34:35Z" level=debug msg="http: TLS handshake error from 185.188.35.10:7815: remote error: tls: unknown certificate"
time="2022-04-29T13:34:37Z" level=debug msg="Serving default certificate for request: \"self.dev.mydomain.com\""

```

Here is my docker-compose.yaml

```auto
version: "3.3"

services:

  traefik:
    image: "traefik:v2.6"
    container_name: "traefik"
    command:
      - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--providers.file.directory=/etc/certs/"
      - "--providers.file.watch=true"
    ports:
      - "443:443"
      - "8080:8080"
      - "80:80"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "./certs:/etc/certs"

  fcc:
    image: "nginx"
    container_name: "fcc"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.fcc.rule=Host(`self.dev.mydomain.com`)"
      - "traefik.http.routers.fcc.entrypoints=websecure"
      - "traefik.http.routers.fcc.tls=true"

```

and the  
tls.yaml

```auto
tls:
  certificates:
    - certFile: ./dev.mydomain.com.crt
      keyFile: ./dev.mydomain.com.key

```

Where do I do wrong?

---

<div class="post-metadata">

**Author:** ![stevegroom](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/stevegroom/32/1696_2.png) [@stevegroom](https://community.traefik.io/u/stevegroom)\
**Post date:** [April 30, 2022, 8:42am UTC](https://community.traefik.io/t/using-own-certificate/14310/2 "2022-04-30T08:42:49Z")

</div>

Does your certificate dev.mydomain.com.crt contain a SAN (Subject Alternate Name) field self.mydomain.com.crt or even \*.dev.mydomain.com.crt ?

Steve

---

<div class="post-metadata">

**Author:** ![celcin](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@celcin](https://community.traefik.io/u/celcin)\
**Post date:** [May 1, 2022, 12:28pm UTC](https://community.traefik.io/t/using-own-certificate/14310/3 "2022-05-01T12:28:29Z")

</div>

> [@stevegroom](#):
>
> [ev.mydomain.co](http://ev.mydomain.co)

Hi Steve,

Here is how SAN looks:  
X509v3 Subject Alternative Name:  
DNS:dev.mydomain.com, DNS:\*.dev.mydomain.com

---

<div class="post-metadata">

**Author:** ![stevegroom](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/stevegroom/32/1696_2.png) [@stevegroom](https://community.traefik.io/u/stevegroom)\
**Post date:** [May 1, 2022, 12:58pm UTC](https://community.traefik.io/t/using-own-certificate/14310/4 "2022-05-01T12:58:16Z")

</div>

Not sure you have the certs location correct - the reference is from the inside of the container - therefore /etc/certs...

```yaml
tls:
  certificates:
    - certFile: /etc/certs/dev.mydomain.com.crt
      keyFile: /etc/certs/dev.mydomain.com.key

```

---

<div class="post-metadata">

**Author:** ![celcin](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@celcin](https://community.traefik.io/u/celcin)\
**Post date:** [May 1, 2022, 8:40pm UTC](https://community.traefik.io/t/using-own-certificate/14310/5 "2022-05-01T20:40:58Z")

</div>

> [@stevegroom](#):
>
> ```auto
> tls:
> certificates:
> - certFile: /etc/certs/dev.mydomain.com.crt
> keyFile: /etc/certs/dev.mydomain.com.key
> 
> ```

I have tried different ways but still getting same issue.

---

<div class="post-metadata">

**Author:** ![stevegroom](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/stevegroom/32/1696_2.png) [@stevegroom](https://community.traefik.io/u/stevegroom)\
**Post date:** [May 2, 2022, 5:41am UTC](https://community.traefik.io/t/using-own-certificate/14310/6 "2022-05-02T05:41:32Z")

</div>

Take a look at this:

> **[Traefik Proxy 2.x and TLS 101 \[Updated 2022\] | Traefik Labs](https://traefik.io/blog/traefik-2-tls-101-23b4fbee81f1/)**
>
> In this article, we explore how Traefik Proxy deals with the HTTPS burden that is TLS termination, leaving your pristine service unspoiled by mundane technical details.

specifically “Specifying a default certificate“

---

<div class="post-metadata">

**Author:** ![celcin](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@celcin](https://community.traefik.io/u/celcin)\
**Post date:** [May 2, 2022, 6:39am UTC](https://community.traefik.io/t/using-own-certificate/14310/7 "2022-05-02T06:39:25Z")

</div>

This was my first and main guide, but I must say It is not written clearly, and I did 1:1 as described in the article by altering corresponding part, still no success. ☹

---

<div class="post-metadata">

**Author:** ![stevegroom](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/stevegroom/32/1696_2.png) [@stevegroom](https://community.traefik.io/u/stevegroom)\
**Post date:** [May 2, 2022, 12:59pm UTC](https://community.traefik.io/t/using-own-certificate/14310/8 "2022-05-02T12:59:19Z")

</div>

From your traefik config, the nginx container is listening on https ( traefik.http.routers.fcc.entrypoints=websecure ). Did you install the same certificate on the nginx server?

What do you get if you connect directly to your nginx service with https?

My next step would be to test https to traefik (terminating the https) and then using http to nginx...

Steve
