Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

autoTls: bound certificate lifetime by the CA that will actually sign it, not the configured caCertificateLifetime

オープン
#753 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
kubernetes, rust

調査の方向性

NodePublishVolume がバックエンドを構築する際に呼び出される TlsGenerate::get_or_create_k8s_certificate から始め、Secret の CA 証明書を読み込む ca::Manager::load_or_create を調査します。CA のうち最も遅い有効期限を使用して有効期間の上限を実装し、現在時刻に再起動バッファを加えた時点をカバーする CA がない場合の既存のハードな失敗は維持します。既存の警告または条件の動作を確認し、関連するテストで証明書の有効期間と失敗のエッジケースを検証します。

索引モデルが issue の本文から書いたものです。

説明

get_or_create_k8s_certificate clamps maxCertificateLifetime to (caCertificateLifetime - caCertificateRetirementDuration) / 4.
That is good in general, bad when someone brings their own CA as secret operator never looks at the actual CA that is provided. It just looks at what is in the CR:

    ca:
        secret:
          name: secret-provisioner-tls-ca
          namespace: default
        autoGenerate: false
        caCertificateLifetime: 700d
        caCertificateRetirementDuration: 1d

maxCertificateLifetime = (700 - 1) / 4 = 174 (or 175, not sure, doesn't matter here)

That clamps to 174d . But we have no idea what's really in the CA.

If it has 200 days left:

  • above 174 days remaining: works
  • 174 down to 139: flip-flops, because jitter puts each cert somewhere in 139-174d and only some of them still fit
  • below 139: every mount fails

That is not great.
It only happens when autoGenerate is false, but still....

Scope

  • Calculate the clamp by looking at the CA in the Secret that expires last
  • Keep it a hard failure where no CA covers now + restartBuffer
  • Warning Event and/or condition on the Pod when the cert had to be shortened because of the CA's remaining lifetime?
    • Open question....do we do this elsewhere? Easy to do? I think it'd be good.

[!NOTE]
This next bit is complicated and I'm not 100% sure it is all correct. I think it makes sense but I have a nagging feeling that something is still off. It is 100% written by hand but I'm not sure if the new steps 3 & 4 are correct to be honest. So many edge cases.

When a pod mounts a TLS volume, NodePublishVolume builds the backend for that SecretClass.
For autoTls that is TlsGenerate::get_or_create_k8s_certificate, which does, in this order:

  1. safe_max_cert_lifetime = (caCertificateLifetime - caCertificateRetirementDuration) / 4, from the CR fields
  2. max_cert_lifetime = min(maxCertificateLifetime, safe_max_cert_lifetime). This is the clamp.
  3. ca::Manager::load_or_create, which reads the CA certificates from the Secret

We need to load the CAs (step 3) before computing the clamp (step 2), and additionally bound it (the max cert lifetime) by the remaining lifetime (not_after - now, minus caCertificateRetirementDuration) of the CA that expires last. This way we never create certificates that can outlive the last expiring CA.

  1. ca::Manager::load_or_create, reads the CA certificates from the Secret
  2. safe_max_cert_lifetime = (caCertificateLifetime - caCertificateRetirementDuration) / 4, from the CR, unchanged
  3. ca_bound = not_after(CA that expires last) - now - caCertificateRetirementDuration, from the loaded certificates. This is new.
  4. max_cert_lifetime = min(maxCertificateLifetime, safe_max_cert_lifetime, ca_bound)

[!NOTE]
Do we even still need safe_max_cert_lifetime? I believe it makes sure that all Pods can still talk to each other even if some already have a new CA and others don't but 🤯

Open questions

  • Check the existing warnings whether they are correctly calculated and/or whether we want something new
  • Event or Pod condition or both? An Event per mount is noisy on a large StatefulSet, otoh we might want noisy in this case?
  • I believe it'd be easy to fold #94 into this. If you agree and it adds less than a day you're welcome to do so. Otherwise skip.
    • I understand that this is underspecified but at least a log line and maybe another condition woudl be good here?

Out of scope

  • Validating the SecretClass on admission

Expected effort

1-2 days. If it takes longer, stop and flag it.

主要言語
Rust
スター
13
フォーク
8
平均マージ
1日 8時間
マージ済み PR(30日)
10

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

stackabletech/secret-operator のほかの issue

stackabletech/secret-operator の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。