@@ -173,9 +173,11 @@ The ExternalSecret on the site cluster combines these into a single
173173` tls.key ` , and ` ca.crt ` . This secret is mounted into worker pods at
174174` /etc/nautobot/mtls/ ` .
175175
176- Note: if your secrets provider stores PEM data with ` \r\n ` line endings,
177- the ExternalSecret template must strip carriage returns
178- (` | replace "\r" "" ` ) or OpenSSL will fail to parse the certificates.
176+ Note: if your secrets provider stores PEM data with ` \r\n ` line endings
177+ or concatenates multiple PEM blocks in a single field, use the
178+ [ ` filterPEM ` ] ( https://external-secrets.io/latest/guides/templating/#filter-pem-blocks )
179+ template function to extract specific block types. ` filterPEM ` handles
180+ carriage-return stripping automatically.
179181
180182## Adding a New Site
181183
@@ -298,16 +300,9 @@ spec:
298300 engineVersion : v2
299301 type : kubernetes.io/tls
300302 data :
301- tls.crt : >-
302- {{ .client_password
303- | regexFind "-----BEGIN CERTIFICATE-----[\\s\\S]*?-----END CERTIFICATE-----"
304- | replace "\r" "" }}
305- tls.key : >-
306- {{ .client_password
307- | regexFind "-----BEGIN EC PRIVATE KEY-----[\\s\\S]*?-----END EC PRIVATE KEY-----"
308- | replace "\r" "" }}
309- ca.crt : >-
310- {{ .ca_password | replace "\r" "" }}
303+ tls.crt : ' {{ .client_password | filterPEM "CERTIFICATE" }}'
304+ tls.key : ' {{ .client_password | filterPEM "EC PRIVATE KEY" }}'
305+ ca.crt : ' {{ .ca_password | filterPEM "CERTIFICATE" }}'
311306 dataFrom :
312307 - extract :
313308 key : " <client-cert-credential-id>"
@@ -325,9 +320,10 @@ spec:
325320
326321{% endraw %}
327322
328- The ` replace "\r" ""` strips carriage returns that some secrets
329- providers add to PEM data. Without this, OpenSSL will fail to parse
330- the certificates.
323+ The [` filterPEM`](https://external-secrets.io/latest/guides/templating/#filter-pem-blocks)
324+ function extracts PEM blocks by type and strips carriage returns
325+ automatically. Pass the PEM block type without the `BEGIN`/`END`
326+ markers (e.g. `"CERTIFICATE"`, `"EC PRIVATE KEY"`, `"PRIVATE KEY"`).
331327
332328# ## Step 4: Create the kustomization
333329
@@ -534,8 +530,11 @@ operator guide.
534530
535531- **PEM data with carriage returns.** Some secrets providers store text
536532 with `\r\n` line endings. PEM certificates with `\r` characters will
537- fail OpenSSL parsing with `[SSL] PEM lib`. The ExternalSecret template
538- must strip carriage returns using `| replace "\r" ""`.
533+ fail OpenSSL parsing with `[SSL] PEM lib`. Use the
534+ [`filterPEM`](https://external-secrets.io/latest/guides/templating/#filter-pem-blocks)
535+ template function to extract PEM blocks by type -- it handles
536+ carriage-return stripping automatically. Avoid manual `regexFind` +
537+ ` replace "\r " ""` patterns.
539538
540539- **ExternalSecret format depends on your secrets provider.** The
541540 ExternalSecret for the mTLS client cert on site clusters must produce
0 commit comments