Skip to content

bug: TLSStore with Wildcard Certificate and sniStrict: true does not work #10817

@georglauterbach

Description

@georglauterbach

Welcome!

  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've searched similar issues on the Traefik community forum and didn't find any.

What did you do?

I am not sure if this repository or traefik/traefik-helm-chart is the correct repo to open this in, but I am under the impression this might be something in Traefik itself, not in Kubernetes (CRDs).


I am using Cloudflare (CF) Origin Certificates (Traefik can use them to talk to the CF proxies). This is nice because I do not need certificate resolvers like Let'sEncrypt. I was upgrading from v2.10.7 to 3.0.2 and first completely uninstalled all the old CRDs and Traefik, then installed the new version.

All of this worked nicely and I encountered no issues. Here are the relevant definitions:

---
apiVersion: v1
kind: Secret

metadata:
  name: cloudflare-origin-certificate

type: kubernetes.io/tls
immutable: true

data:
  tls.key: A VALID BASE64 KEY VERIFIED WITH OPENSSL
  tls.crt: A VALID BASE64 CERTIFICATE VERIFIED WITH OPENSSL

I am using Helm to deploy Traefik, and inside the values.yaml, I use

tlsStore:
  default:
    defaultCertificate:
      secretName: cloudflare-origin-certificate

All of this lives in the ingress namespace.

I also use TLSOptions:

tlsOptions:
  default:
    minVersion: VersionTLS12
    maxVersion: VersionTLS13
    sniStrict: true
    curvePreferences: [ secp521r1, secp384r1, secp256r1, x25519 ]
    alpnProtocols: [h2, h3]

Assume my domain is mydomain.test. The CF Origin Certificate is valid for *.mydomain.test and mydomain.test.

What did you see instead?

When trying to open subdomain.mydomain.test, what I am now seeing is this, though:

image

It seems Traefik does not use the certificates from my TLSStore anymore. Looking at the debug logs:

TLS: strict SNI enabled - No certificate found for domain: "subdomain.mydomain.test", closing connection
2024-06-16T15:29:05+02:00 DBG log/log.go:245 > http: TLS handshake error from 162.158.110.154:36198: tls: no certificates configured

I am also seeing

2024-06-16T15:15:33+02:00 DBG github.com/traefik/traefik/v3/pkg/tls/tlsmanager.go:321 > No default certificate, fallback to the internal generated certificate tlsStoreName=default

which is unexpected because both the Secret and the TLSStore exist:

$ kubectl describe secrets -n ingress
Name:         cloudflare-origin-certificate-com
Namespace:    ingress
Labels:       <none>
Annotations:  <none>

Type:  kubernetes.io/tls

Data
====
tls.key:  X bytes
tls.crt:  Y bytes

$ kubectl describe tlsstores.traefik.io -n ingress
Name:         default
Namespace:    ingress
Labels:       app.kubernetes.io/instance=traefik-ingress
              app.kubernetes.io/managed-by=Helm
              app.kubernetes.io/name=traefik
              helm.sh/chart=traefik-28.3.0
Annotations:  <none>
API Version:  traefik.io/v1alpha1
Kind:         TLSStore
Metadata:
  Creation Timestamp:  2024-06-16T10:20:37Z
  Generation:          9
  Resource Version:    16866321
  UID:                 288e3946-70d5-41bb-94d3-83771c65c6a8
Spec:
  Default Certificate:
    Secret Name:  cloudflare-origin-certificate
Events:           <none>

What bugs me is the log message

TLS: strict SNI enabled - No certificate found for domain: "subdomain.mydomain.test", closing connection

I used sniStrict: true before as well, though; hence I think SNI should not be the problem here. But, when using sniStrict: false, everything starts to work. Am I misunderstanding something here? I had assumed that with a wildcard certificate, I could use sniStrict: true (like before).


related: traefik/traefik-helm-chart#851

What version of Traefik are you using?

Version:      3.0.2
Codename:     beaufort
Go version:   go1.22.4
Built:        2024-06-10T14:38:51Z
OS/Arch:      linux/amd64

What is your environment & configuration?

See previous fields for relevant configuration snippets. Here is the IngressRoute:

---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute

metadata:
  name: subdomain

spec:
  entryPoints: [ websecure ]

  routes:
    - kind: Rule
      match: Host(`subdomain.mydomain.test`)

      services:
        - name: someservice
          namespace: some-namespace-not-ingress
          port: http
          scheme: http

  tls:
    store:
      name: default
      namespace: ingress

I tried countless different configurations now, omitting the tls section in the IngressRoute, etc.

If applicable, please paste the log output in DEBUG level

2024-06-16T15:15:33+02:00 DBG github.com/traefik/traefik/v3/pkg/tls/tlsmanager.go:321 > No default certificate, fallback to the internal generated certificate tlsStoreName=default
2024-06-16T15:15:58+02:00 DBG github.com/traefik/traefik/v3/pkg/tls/tlsmanager.go:216 > TLS: strict SNI enabled - No certificate found for domain: "subdomain.mydomain.test", closing connection
2024-06-16T15:15:58+02:00 DBG log/log.go:245 > http: TLS handshake error from 172.70.175.27:17586: tls: no certificates configured

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions