Skip to content

Commit 23eee0e

Browse files
lfranckeclaude
andcommitted
Use k8sSearch backend for CA-only server verification
The autoTls backend always issues and signs per-pod certificates and therefore requires the CA private key (ca.key); it cannot be used to just publish an existing CA certificate. Use the k8sSearch backend instead, which mounts the ca.crt from a labeled Secret into the Pod. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 646fa3e commit 23eee0e

3 files changed

Lines changed: 26 additions & 14 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: openldap-tls-ca
6+
labels:
7+
secrets.stackable.tech/class: openldap-tls-ca # <1>
8+
stringData:
9+
ca.crt: | # <2>
10+
-----BEGIN CERTIFICATE-----
11+
...
12+
-----END CERTIFICATE-----

modules/concepts/examples/secretclass-server-verification-ca.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ metadata:
55
name: openldap-tls-ca # <1>
66
spec:
77
backend:
8-
autoTls:
9-
ca:
10-
secret:
11-
name: openldap-tls-ca # <2>
12-
namespace: default # <3>
13-
autoGenerate: false # <4>
8+
k8sSearch:
9+
searchNamespace:
10+
pod: {} # <2>

modules/concepts/pages/tls-server-verification.adoc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,30 @@ include::example$tls-server-verification-custom-ca.yaml[]
4747
----
4848

4949
The referenced `openldap-tls-ca` SecretClass does not exist yet, you have to create it.
50+
For server verification you only need to make the CA certificate available to the product as-is, so you use the xref:secret-operator:secretclass.adoc#backend-k8ssearch[`k8sSearch` backend], which mounts the contents of a Kubernetes Secret into the Pod.
5051
A SecretClass used only for server verification needs nothing but the CA certificate, it does not need a key.
5152
So if you were provided with a CA certificate but do not have access to its key, you can still use this method.
5253

53-
First, store the CA certificate (in PEM format) that you were given in a Kubernetes Secret, under the key `ca.crt`:
54+
First, store the CA certificate (in PEM format) that you were given in a Secret.
55+
The Secret must carry the label `secrets.stackable.tech/class` matching the SecretClass name, and the CA certificate must be stored under the key `ca.crt`:
5456

55-
[source,bash]
57+
[source,yaml]
5658
----
57-
kubectl create secret generic openldap-tls-ca --from-file=ca.crt=/path/to/ca.crt
59+
include::example$secret-server-verification-ca.yaml[]
5860
----
5961

60-
Then create a SecretClass that uses the xref:secret-operator:secretclass.adoc#backend-autotls[`autoTls` backend] to reference this Secret:
62+
<1> This label must match the name of the SecretClass created below.
63+
<2> The CA certificate in PEM format.
64+
65+
Then create the SecretClass that uses the `k8sSearch` backend to find that Secret:
6166

6267
[source,yaml]
6368
----
6469
include::example$secretclass-server-verification-ca.yaml[]
6570
----
6671

67-
<1> The name of the SecretClass, this is what `caCert.secretClass` above refers to.
68-
<2> The name of the Secret created above, which holds the CA certificate in its `ca.crt` entry. `ca.key` is not required for server verification.
69-
<3> The namespace the Secret lives in.
70-
<4> Disables CA generation so that the Secret Operator uses the provided CA as-is instead of generating its own. This is the default and may be omitted.
72+
<1> The name of the SecretClass, this is what `caCert.secretClass` above refers to. It must match the Secret's `secrets.stackable.tech/class` label.
73+
<2> The backend looks for the labeled Secret in the same namespace as the Pod that consumes the certificate.
7174

7275
=== Mutual verification
7376
This example will use TLS and verify both - the server and the client using certificates.

0 commit comments

Comments
 (0)