# Custom SSL certificate results in runtime error

**URL:** <https://community.traefik.io/t/custom-ssl-certificate-results-in-runtime-error/9592>\
**Category:** Traefik v2\
**Tags:** file, docker\
**Created:** [February 5, 2021, 2:20pm UTC](https://community.traefik.io/t/custom-ssl-certificate-results-in-runtime-error/9592 "2021-02-05T14:20:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaavdeev](https://avatars.discourse-cdn.com/v4/letter/v/ed655f/32.png) [@vaavdeev](https://community.traefik.io/u/vaavdeev)\
**Post date:** [February 5, 2021, 2:20pm UTC](https://community.traefik.io/t/custom-ssl-certificate-results-in-runtime-error/9592/1 "2021-02-05T14:20:58Z")

</div>

I'm trying to use custom SSL certificate with Traefik, but it doesn't work and when I login to [my.domain.com](http://my.domain.com) it serves TRAEFIK DEFAULT CERT instead, while logs (from `sudo docker logs traefik`) show some runtime and handshake errors:

```auto
time="2021-02-04T20:43:02Z" level=debug msg="http: panic serving 192.168.9.195:63243: runtime error: invalid memory address or nil pointer dereference"
...
time="2021-02-04T20:43:02Z" level=debug msg="No default certificate, generating one"
time="2021-02-04T20:43:02Z" level=debug msg="Serving default certificate for request: \"my.domain.com\""
...
time="2021-02-04T20:43:05Z" level=debug msg="http: TLS handshake error from 192.168.204.49:52373: remote error: tls: unknown certificate"

```

SSL certificate is bundled from multiple ones in correct order and passes all possible checks I've [found](https://support.acquia.com/hc/en-us/articles/360004119234-Verifying-the-validity-of-an-SSL-certificate). (At first there were some `failed to find any PEM data in certificate input` errors, but after changes in bundling and file paths they are gone.)

The project folder structure and config files look like that:  
/home/user/traefik/certificates/my.domain.com.crt (and .key)  
/home/user/application

traefik.toml in /home/user/traefik:

```auto
[entryPoints]
  [entryPoints.web]
    address = ":80"

  [entryPoints.web.http]
    [entryPoints.web.http.redirections]
      [entryPoints.web.http.redirections.entryPoint]
        to = "websecure"
        scheme = "https"

  [entryPoints.websecure]
    address = ":443"

[log]
  level = "DEBUG"

[accessLog]
  filePath = "access.log"

[providers]
  [providers.docker]
    watch = true
    network = "web"

  [providers.file]
    directory = "/certificates/"
    watch = true
    filename = "/dynamic.toml"

```

dynamic.toml in /home/user/traefik:

```auto
[tls]
  [[tls.certificates]]
    certFile = "/certificates/my.domain.com.crt"
    keyFile = "/certificates/my.domain.com.key"
    stores = ["default"]

```

Script run\_traefik.sh in /home/user/traefik folder:

```auto
docker stop traefik

docker rm traefik

docker run -d \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v $PWD/traefik.toml:/traefik.toml \
  -v $PWD/dynamic.toml:/dynamic.toml \
  -v $PWD/traefik.log:/traefik.log \
  -v $PWD/access.log:/access.log \
  -v $PWD/certificates/:/certificates/ \
  -p 80:80 \
  -p 443:443 \
  --network web \
  --name traefik \
  traefik:v2.4.2

```

Part of docker-compose.yml in /home/user/application:

```auto
version: '3.0'

services:
  ...
  application:
    ...
    labels:
      - traefik.http.routers.seatable.rule=Host(`my.domain.com`)
      - traefik.http.routers.seatable.tls=true
    networks:
      - application-net
      - web

networks:
  application-net:
    external: false
  web:
    external: true

```

What should I change to make it work?

---

<div class="post-metadata">

**Author:** ![cakiwi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cakiwi/32/3205_2.png) [@cakiwi](https://community.traefik.io/u/cakiwi)\
**Post date:** [February 6, 2021, 4:29pm UTC](https://community.traefik.io/t/custom-ssl-certificate-results-in-runtime-error/9592/2 "2021-02-06T16:29:09Z")

</div>

Hi @vaavdeev

You have conflicting conofiguration using both directory and file. Pretty sure this is using the directory watchand not finding any configuration.

> [@vaavdeev](#):
>
> ```auto
> [providers.file]
> directory = "/certificates/"
> watch = true
> filename = "/dynamic.toml"
> 
> ```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [February 10, 2021, 1:50pm UTC](https://community.traefik.io/t/custom-ssl-certificate-results-in-runtime-error/9592/3 "2021-02-10T13:50:47Z")

</div>

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