Skip to content

fix(traefik): copy all traefik certs from project to router, fixes #8100, replaces #8108 - #8113

Merged
rfay merged 3 commits into
ddev:mainfrom
rfay:20260206_rfay_minimal_multiple_certs
Feb 7, 2026
Merged

rfay merged 3 commits into
ddev:mainfrom
rfay:20260206_rfay_minimal_multiple_certs

Conversation

@rfay

@rfay rfay commented Feb 6, 2026 •

Copy link
Copy Markdown
Member

The Issue

Since DDEV v1.25.0, only certificates named exactly <projectname>.crt and <projectname>.key are copied from .ddev/traefik/certs/ to the router. This prevents users from placing additional certificates (e.g., mTLS CA certs) in the project's traefik certs directory and having them available for use in custom Traefik configurations.

NOTE

This is the first commit from #8108

Over there, I tried adding tests that seemed to create new complexities everywhere.

I'd like to see this simple fix succeed, probably with a simple test that simply verifies coverage on what it adds. Then the clear need for traefik custom config test coverage can be addressed separately.

How This PR Solves The Issue

Modified PushGlobalTraefikConfig() in pkg/ddevapp/traefik.go to:

  • Copy ALL .crt and .key files from .ddev/traefik/certs/ instead of only the project-named files
  • Track all copied certificates in expectedCerts map so they won't be removed during cleanup
  • Add debug logging for each copied certificate

This allows users to place any additional certificates (e.g., ca.crt, client.crt, etc.) in .ddev/traefik/certs/ and reference them in custom Traefik configuration files.

Manual Testing Instructions

  1. Create a test project: ddev config --project-type=php
  2. Create a custom certificate in .ddev/traefik/certs/, e.g., .ddev/traefik/certs/custom-ca.crt
  3. Start the project: ddev start
  4. Verify the cert is copied to the router: docker exec ddev-router ls /mnt/ddev-global-cache/traefik/certs/
  5. Confirm custom-ca.crt appears in the list
  6. Create a custom Traefik config that references the cert
  7. Verify it's accessible in the router container

Automated Testing Overview

  • Existing TestTraefikSimple test passes - verifies basic cert handling
  • Existing TestCustomGlobalConfig test passes - verifies custom cert usage
  • No new tests added since existing integration tests cover the cert copying functionality

Release/Deployment Notes

This is a bug fix that restores functionality from pre-v1.25.0. Users who need to use additional certificates (e.g., for mTLS) in custom Traefik configurations can now place them in .ddev/traefik/certs/ and they will be mounted into the router container.

@github-actions github-actions Bot added the bugfix label Feb 6, 2026
@github-actions

github-actions Bot commented Feb 6, 2026 •

Copy link
Copy Markdown

@rfay rfay changed the title fix: copy all traefik certs from project to router, fixes #8100 fix(traefik): copy all traefik certs from project to router, fixes #8100 Feb 6, 2026
@rfay rfay changed the title fix(traefik): copy all traefik certs from project to router, fixes #8100 fix(traefik): copy all traefik certs from project to router, fixes #8100, replaces #8108 Feb 6, 2026
@rfay
rfay marked this pull request as ready for review February 6, 2026 18:34
@rfay
rfay requested a review from a team as a code owner February 6, 2026 18:34
@rfay
rfay requested a review from stasadev February 6, 2026 18:34

@stasadev stasadev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, users can have different certificates with the same name.

I can see this happening when someone has two projects. A cert expires, they update it in one project, and forget to update it in the other.

Anyway, it looks good to me.

rfay and others added 3 commits February 6, 2026 13:51
…skip ci]

- Fixes ddev#8100

Since DDEV v1.25.0, only certificates named exactly `<projectname>.crt` and
`<projectname>.key` are copied from `.ddev/traefik/certs/` to the router.
This prevents users from placing additional certificates (e.g., mTLS CA certs)
in the project's traefik certs directory and having them available for use in
custom Traefik configurations.

Modified `PushGlobalTraefikConfig()` in `pkg/ddevapp/traefik.go` to:
- Copy ALL `.crt` and `.key` files from `.ddev/traefik/certs/` instead of
  only the project-named files
- Track all copied certificates in `expectedCerts` map so they won't be
  removed during cleanup
- Add debug logging for each copied certificate

This allows users to place any additional certificates (e.g., `ca.crt`,
`client.crt`, etc.) in `.ddev/traefik/certs/` and reference them in custom
Traefik configuration files.

1. Create a test project: `ddev config --project-type=php`
2. Create a custom certificate in `.ddev/traefik/certs/`, e.g.,
   `.ddev/traefik/certs/custom-ca.crt`
3. Start the project: `ddev start`
4. Verify the cert is copied to the router:
   `docker exec ddev-router ls /mnt/ddev-global-cache/traefik/certs/`
5. Confirm `custom-ca.crt` appears in the list
6. Create a custom Traefik config that references the cert
7. Verify it's accessible in the router container

- Existing `TestTraefikSimple` test passes - verifies basic cert handling
- Existing `TestCustomGlobalConfig` test passes - verifies custom cert usage
- No new tests added since existing integration tests cover the cert copying
  functionality

This is a bug fix that restores functionality from pre-v1.25.0. Users who need
to use additional certificates (e.g., for mTLS) in custom Traefik
configurations can now place them in `.ddev/traefik/certs/` and they will be
mounted into the router container.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@rfay
rfay force-pushed the 20260206_rfay_minimal_multiple_certs branch from 77908d0 to b883070 Compare February 6, 2026 20:56
@rfay
rfay merged commit 500fc99 into ddev:main Feb 7, 2026
28 checks passed
@rfay
rfay deleted the 20260206_rfay_minimal_multiple_certs branch February 7, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Additional certificate (for mTLS) is no longer mounted in ddev-router since v1.25.0

2 participants