The Traefik v1.7 documentation states:
TLS Mutual Authentication¶
TLS Mutual Authentication can be optional or not.
If optional = true, if a certificate is provided, verifies if it is signed by a specified Certificate Authority (CA). Otherwise proceeds without any certificate.
If optional = false, Traefik will only accept clients that present a certificate signed by a specified Certificate Authority (CA).
ClientCAFiles can be configured with multiple CA:s in the same file or use multiple files containing one or several CA:s. The CA:s has to be in PEM format.
I've created a test self-signed certificate, converted it to the .pem
format and I'm getting the following log output from traefik which is crashing:
PEM
-----BEGIN CERTIFICATE-----
(base64)
-----END CERTIFICATE-----
-----BEGIN PRIVATE KEY-----
(base64)
-----END PRIVATE KEY-----
Logs
{"level":"info","msg":"Using TOML configuration file /config/traefik.toml","time":"2019-07-26T13:12:45Z"}
{"level":"info","msg":"No tls.defaultCertificate given for https: using the first item in tls.certificates as a fallback.","time":"2019-07-26T13:12:45Z"}
{"level":"info","msg":"Traefik version v1.7.12 built on 2019-05-29_07:35:02PM","time":"2019-07-26T13:12:45Z"}
{"level":"info","msg":"\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/basics/#collected-data\n","time":"2019-07-26T13:12:45Z"}
{"level":"info","msg":"Preparing server http \u0026{Address::80 TLS:\u003cnil\u003e Redirect:0xc00018a200 Auth:\u003cnil\u003e WhitelistSourceRange:[] WhiteList:\u003cnil\u003e Compress:true ProxyProtocol:\u003cnil\u003e ForwardedHeaders:0xc0001b9440} with readTimeout=0s writeTimeout=0s idleTimeout=3m0s","time":"2019-07-26T13:12:45Z"}
{"level":"info","msg":"Preparing server https \u0026{Address::443 TLS:0xc000422990 Redirect:\u003cnil\u003e Auth:\u003cnil\u003e WhitelistSourceRange:[] WhiteList:\u003cnil\u003e Compress:true ProxyProtocol:\u003cnil\u003e ForwardedHeaders:0xc0001b93c0} with readTimeout=0s writeTimeout=0s idleTimeout=3m0s","time":"2019-07-26T13:12:45Z"}
{"level":"fatal","msg":"Error preparing server: error creating TLS config: invalid certificate(s) in /mtls/clientCaCert-0.crt","time":"2019-07-26T13:12:45Z"}
Q1: I believe I may have messed something up at the certificate creation/transformation level
Can you recommend what is the proper way to have this setup with OpenSSL ?
Q2: There's currently a PR open which is aiming to add mTLS support to the helm chart.
I believe @daniel.tomcej was reviewing this
One of the code fragments inside is:
{{- define "traefik.ssl.mtls.clientCAs" -}}
files = [
{{- range $idx, $_ := .Values.ssl.mtls.clientCaCerts }}
{{- if $idx }}, {{ end }}
{{- printf "/mtls/clientCaCert-%d.crt" $idx | quote }}
{{- end -}}
]
{{- end -}}
The above fragment renders .crt
files - doesn't that violate the PEM
format requirement?