Skip to content

chore(tls): cleanup sample yaml + auto cert for client auth#430

Merged
ahrtr merged 1 commit into
etcd-io:customized-controllerfrom
silentred:tls-step1-sample-and-cert
Jul 16, 2026
Merged

chore(tls): cleanup sample yaml + auto cert for client auth#430
ahrtr merged 1 commit into
etcd-io:customized-controllerfrom
silentred:tls-step1-sample-and-cert

Conversation

@silentred

@silentred silentred commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

sub-task 1 of #428

Questions might be asked:

  • Why change sample yaml?
    time.ParseDuration cannot parse strings like 365d. v0.2.0 produces the same error. If support for parsing the d suffix is desired, it can be addressed in a follow-up PR.

  • Why add ClientAuth usage to cert?
    The controller is supposed use the server TLS certificate as the etcd client certificate to talk to the etcd server; it does not use client TLS.
    Because the client ca.crt is issued by an independent CA and is not included in the etcd server's --trusted-ca-file, client TLS cannot complete a handshake with the etcd server today.
    Future work: bundle the client CA together with the server CA and add the bundle to the etcd server's trust chain (--trusted-ca-file). Once that is in place, client TLS will be able to communicate with the etcd server normally.

/cc @ahrtr @nwnt

@ahrtr

ahrtr commented Jul 16, 2026

Copy link
Copy Markdown
Member

link to #409 and #362

Comment thread pkg/certificate/auto/provider.go Outdated
Comment on lines +297 to +299
// transport.SelfCert generates a self-signed cert whose ExtKeyUsage
// defaults to ServerAuth only. The operator reuses the server Secret
// as its own mTLS client identity against the etcd client listener.

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.

Suggested change
// transport.SelfCert generates a self-signed cert whose ExtKeyUsage
// defaults to ServerAuth only. The operator reuses the server Secret
// as its own mTLS client identity against the etcd client listener.
// transport.SelfCert generates a self-signed cert whose ExtKeyUsage
// defaults to ServerAuth only. The operator reuses the server Secret
// as its own mTLS client identity talking with the etcd cluster.

// defaults to ServerAuth only. The operator reuses the server Secret
// as its own mTLS client identity against the etcd client listener.
// The cert must also carry ClientAuth.
tlsInfo, selfCertErr := transport.SelfCert(zap.NewNop(), tmpDir, hosts, validityYears, x509.ExtKeyUsageClientAuth)

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.

I am curious why we did not see any issue previously without x509.ExtKeyUsageClientAuth? cc @ArkaSaha30

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What I see is that etcdserver pod has never enabled TLS args.

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.

What I see is that etcdserver pod has never enabled TLS args.

Just double checked the source code on main branch, this is true. We mounted the secret into POD, but actually do not use it at all. Peers talk to each other use http always, and etcd-operator talks to etcd via http always as well.

We missed such an elephant!

Signed-off-by: shenmu.wy <shenmu.wy@antfin.com>
@ahrtr

ahrtr commented Jul 16, 2026

Copy link
Copy Markdown
Member
  • Because the client ca.crt is issued by an independent CA and is not included in the etcd server's --trusted-ca-file, client TLS cannot complete a handshake with the etcd server today.

I think this is a good catch. But why we did not see any issue previously with Statefulset? The etcd-operator needs to perform health check, it should fail right? @ArkaSaha30 did you see any issue previously when you were testing the feature?

@ahrtr ahrtr 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.

Good catch! Thanks.

autoCfg:
commonName: "etcd-operator-system"
validityDuration: 365d
validityDuration: 8760h No newline at end of file

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.

We need to consider an alternative utility to replace the time.ParseDuration, we should support duration like "365d"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, there gona be some research work. Do you mind that I handle it in a follow-up PR?

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.

Do you mind that I handle it in a follow-up PR?

sure

@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahrtr, silentred

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@silentred
silentred force-pushed the tls-step1-sample-and-cert branch from ff197c3 to e9a33e9 Compare July 16, 2026 09:21
@ahrtr
ahrtr merged commit 1346d88 into etcd-io:customized-controller Jul 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants